Skip to content

Instantly share code, notes, and snippets.

@anthonysousa
Last active April 4, 2024 20:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anthonysousa/334b1c588667315f996d to your computer and use it in GitHub Desktop.
Save anthonysousa/334b1c588667315f996d to your computer and use it in GitHub Desktop.
Rename multiple files on Mac Terminal to lowercase and replace the spaces

First, make sure you are on the right directory on mac terminal app.

If you want to change only jpg files you can use $ for f in *.JPG; instead of $ for f in *;

Renaming to lowercase

$ for f in *; do mv "$f" "`echo $f | tr "[:upper:]" "[:lower:]"`"; done

Replacing spaces in file names to hyphens

$ for f in *; do mv "$f" "`echo $f | tr " " "-"`"; done

Use \000 to remove characters

$ for f in *; do mv "$f" "`echo $f | tr "," "\000"`"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment