Skip to content

Instantly share code, notes, and snippets.

@nooptr
Last active December 13, 2018 03:11
Show Gist options
  • Save nooptr/f927e8d4f58c686a511e3ba72ac99f55 to your computer and use it in GitHub Desktop.
Save nooptr/f927e8d4f58c686a511e3ba72ac99f55 to your computer and use it in GitHub Desktop.
#!/bin/bash
# ex: rename file test.jpg?w=12&h=15 to test.jpg
for FILE in *; do mv $FILE ${FILE%\?*}; done
# tham khao:
# https://unix.stackexchange.com/questions/33279/how-can-i-rename-multiple-files-by-removing-a-character-or-string
# ${i%-*} matches the begining of the filename up to the last occurrence of the dash -
# ${file##*-} matches the rest of the filename after the last occurrence of the dash -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment