Skip to content

Instantly share code, notes, and snippets.

@nexxos
Last active December 20, 2015 17:58
Show Gist options
  • Save nexxos/6171949 to your computer and use it in GitHub Desktop.
Save nexxos/6171949 to your computer and use it in GitHub Desktop.
Bulk renaming files using Mac's Bash. Prepending string to files of a given type.
# You want to rename all files of a certain kind in a directory,
# prepending an arbitrary string to file names.
# Put files in a folder and cd there in the terminal.
# This Example looks for any flash video files (.flv)
# inside the current directory and prepends "movie_" to each file name.
# Here be magic:
for f in *.flv; do mv "$f" "movie_$f"; done
# If file renaming produces error, check file permissions
ls -lha
# if there are no 'w's under permissions:
chmod 755 *
# to make files writable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment