Skip to content

Instantly share code, notes, and snippets.

@tsleyson
Created February 15, 2018 17:52
Show Gist options
  • Save tsleyson/18c98c989c4bbebde0e8257f8071ef55 to your computer and use it in GitHub Desktop.
Save tsleyson/18c98c989c4bbebde0e8257f8071ef55 to your computer and use it in GitHub Desktop.
Rename files in directory with some prefix to remove the prefix
# 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