Skip to content

Instantly share code, notes, and snippets.

@rdmarsh
Last active December 22, 2015 21:19
Show Gist options
  • Save rdmarsh/6532254 to your computer and use it in GitHub Desktop.
Save rdmarsh/6532254 to your computer and use it in GitHub Desktop.
pad files to 8.3, fill with zeros
#!/usr/bin/env bash
# Pad a range of file names with extra zeros
# AA012345.EXT = AA012345.EXT
# BB012345.EXT = BB012345.EXT
# ABC.EXT = ABC00000.EXT
# ABCDE.EXT = ABCDE0000.EXT
for orgfilename in *.EXT ; do
#slice of EXT and add zeros
newfilename="${orgfilename%%.*}00000000"
#slice down to 8 chars and add EXT back on
newfilename="${newfilename:0:8}.EXT"
mv "${orgfilename}" "${newfilename}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment