Last active
December 20, 2015 17:58
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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