I don’t want to waste time doing things manually when I can run a script that will help me save time and effort.
When using Linux or Mac command line (bash?), if you want to rename all files in your present directory and replace all hyphens -
with underscores _
, run this command:
1 |
for f in *-*; do mv "$f" "${f//-/_}"; done |
And if you want to do the reverse, i.e., replace all underscores _
with hyphens -
, run this command instead:
1 |
for f in *_*; do mv "$f" "${f//_/-}"; done |
To remove substring from file names, (e.g., remove @3x
string), run this:
1 |
for f in *@3x*; do mv "$f" "${f//@3x/}"; done |
I had to do this after importing image files with hyphens in their names into my Android project. I can’t use images with hyphens in their names.