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.
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.
Unless you need a solution you can use in a script, you can do this directly in Finder.
There 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.
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
.
– Pysis
Apr 12 '17 at 20:39
mv
could backfire if you're not already good with the syntax needed.. – bmike Apr 12 '17 at 08:46perl rename
- http://search.cpan.org/~pederst/rename-1.9/bin/rename.PL – fd0 Apr 12 '17 at 12:44