Created
June 4, 2017 13:58
-
-
Save ckunte/f68e7fae942b31d4148ff3b781c2b0cd to your computer and use it in GitHub Desktop.
Remove spaces and special characters from file and folder names (in zsh)
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
#!/usr/bin/env zsh | |
autoload -U zmv | |
# Safety first: Always use -n switch to test changes before commit. | |
# Clean up file names in subdirectories and remove special characters | |
zmv -n '(**/)(*)' '$1${2//[^A-Za-z0-9.-]/_}' | |
# Replace spaces in filenames and folders with a hyphen | |
zmv -n '* *' '$f:gs/ /-' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment