Skip to content

Instantly share code, notes, and snippets.

@csabapalfi
Created December 2, 2011 23:27
Show Gist options
  • Save csabapalfi/1425326 to your computer and use it in GitHub Desktop.
Save csabapalfi/1425326 to your computer and use it in GitHub Desktop.
Pad filenames with zeros in bash
#!/bin/bash
maxLength=8
for file in `find *`
do
if [ ${#file} -lt $maxLength ]
then
newFile=$file
while [ ${#newFile} -lt $maxLength ]
do
newFile=0${newFile}
done
mv $file $newFile
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment