Skip to content

Instantly share code, notes, and snippets.

@githubhy
Last active March 20, 2021 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save githubhy/711365e384e99303a96cf05e0829b2d6 to your computer and use it in GitHub Desktop.
Save githubhy/711365e384e99303a96cf05e0829b2d6 to your computer and use it in GitHub Desktop.
Rename file on macOS (one-liner perl)
# [Example] mv 818210-021-english-vocabulary-devious-devout.mp3?blob_id=1265211 021-english-vocabulary-devious-devout.mp3
# [Perl switches] https://perl101.org/command-line-switches.html
# Use "chomp" to remove '\n' from "$_". See https://perldoc.perl.org/functions/chomp
ls | perl -pe 'chomp;s/^\d+-(\d{3}-.*\.mp3)\?.*$/mv $_ $1 \n/' | sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment