I have a bunch of files named similar to this:
1_1.pngEND1_1.png
How would you replace .pngEND
with _
?
I've googled this problem and tried literally 5+ solutions, non of which worked on mac.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityThere are tons of ways to do this, for instance
for i in *pngEND*.png; do [[ -e ${i/.pngEND/_} ]] || echo mv "$i" "${i/.pngEND/_}"; done
Remove the echo
if the output looks sensible.
Unless you need a solution you can use in a script, you can do this directly in Finder.
If your not familier with terminal or scripts, you can use the mac app called NameChanger (free to use). You can change almost everything in batch on filenames / file extentions.
If I had to do this, I'd use rename command available for install via HomeBrew.
Example:
Setup:
mac:test user$ touch 1_1.pngEND1_1.png
mac:test user$ ls
1_1.pngEND1_1.png
Run rename command:
mac:test user$ rename 's/\.pngEND/_/' *.pngEND*
Result:
mac:test user$ ls
1_1_1_1.png
I've also used the perl rename
tool to some success. It also has a dry run option so you can test before you execute the changes.
perl-rename
.
mv
could backfire if you're not already good with the syntax needed..perl rename
- search.cpan.org/~pederst/rename-1.9/bin/rename.PL