I downloaded Udacity videos for a course and the file names look like this:
'78 - Concurrency Bug Depth Solution.mp4'
'79 - Cuzz Algorithm.mp4'
'7 - Dynamic Program Analysis.mp4'
'80 - Probabilistic Guarantee.mp4'
'81 - Proof of Guarantee (Sketch).mp4'
'82 - Measured vs. Worst-Case Probability.mp4'
'86 - Coverage of Random Testing.mp4'
'88 - Intro to Automated Test Generation.mp4'
'89 - Outline.mp4'
'8 - Static Program Analysis.mp4'
'90 - Korat.mp4'
'91 - The Problem.mp4'
'92 - An Insight.mp4'
'94 - Scheme for Representing Shapes.mp4'
'95 - Representing Shapes.mp4'
'96 - Representing Shapes Solution.mp4'
'97 - A Simple Algorithm.mp4'
'98 - Enumerating Shapes.mp4'
'99 - Enumerating Shapes Solution.mp4'
'9 - Program Invariants.mp4'
'396 - Execution Path of a Program.mp4'
'397 - Computation Tree Example.mp4'
'398 - Existing Approach I.mp4'
'399 - Existing Approach II.mp4'
'39 - Conditions Example.mp4'
'3 - Ariane Rocket Disaster.mp4'
'400 - Combined Approach.mp4'
'401 - An Illustrative Example .mp4'
'402 - Computation Tree.mp4'
'403 - Computation Tree Solution.mp4'
.
.
.
from 1 to 419 I believe.
I saw this: https://walkingrandomly.com/?p=2850
but that gives an error:
mv: target '009' is not a directory
How can I modify the bash script to rename these files with padded zeros?
"$foo"
instead of$foo
. Using a shell function instead of a script might be faster. – Bodo May 23 '22 at 15:53ls
command, the filenames may not actually "have quotation marks around them" - see for example Why is 'ls' suddenly wrapping items with spaces in single quotes? – steeldriver May 23 '22 at 15:56*.mp4
) will not escape the spaces when it passes filenames to the script, so the script sees each piece of the filename separated by a space as a separate filename – Esther May 23 '22 at 16:00