Created
February 15, 2018 17:52
-
-
Save tsleyson/18c98c989c4bbebde0e8257f8071ef55 to your computer and use it in GitHub Desktop.
Rename files in directory with some prefix to remove the prefix
This file contains 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
# It doesn't seem to work if you put the prefix in quotes. | |
# The wildcard expansion doesn't pan out. | |
for file in The\ prefix\ *; do | |
mv "$file" "${file#The\ prefix\ }" | |
done | |
# You can do this inside instead if you want to remove | |
# a suffix. | |
mv "$file" "${file%\ the\ suffix}" | |
# See https://stackoverflow.com/a/25536935/3376926 for more information | |
# (including the deal with ## and %%). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment