Skip to content

Instantly share code, notes, and snippets.

@kimchaily
Created February 8, 2014 00:30
Show Gist options
  • Save kimchaily/8874760 to your computer and use it in GitHub Desktop.
Save kimchaily/8874760 to your computer and use it in GitHub Desktop.
Batch renaming in Terminal (e.g. bash) using RegEx
// Example: replace every capital letter with 'abc', only changing m4a-files
for file in *.m4a ; do mv -vf "$file" "`echo $file | sed -E 's/[A-Z]/abc/g'`" ; done
// Sublime-Text snippet:
<snippet>
<content><![CDATA[
for file in *.${1:m4a} ; do mv -vf "\$file" "`echo \$file | sed -E 's/${2:[A-Z]}/${0:abc}/g'`" ; done
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>rename</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment