Renaming many files in Mac OS X, batch processing
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops
--
Chapters
00:00 Renaming Many Files In Mac Os X, Batch Processing
00:17 Answer 1 Score 4
00:50 Accepted Answer Score 21
01:11 Answer 3 Score 29
01:27 Answer 4 Score 5
01:43 Thank you
--
Full question
https://superuser.com/questions/152627/r...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#macos #commandline #regex #rename #batch
#avk47
ANSWER 1
Score 29
Use the power of ZSH wisely (type zsh
in the terminal if you are one of those poor souls who don't use it by default):
autoload zmv
zmv '(*).htm' '$1.html'
ZMV follows MMV syntax.
ACCEPTED ANSWER
Score 21
Clumsy me:
for i in *.yourfiles; do mv "$i" "`echo $i | sed 's/old/new/g'`"; done
And if you want to use it like I do often this way:
rename 's/old/new/' *.files
I recommend to use this litte script in ~/bin/rename:
#!/usr/bin/env zsh
SUBSEXPR=$1
shift
for i in $@; do mv $i `echo "$i" | sed $SUBSEXPR`; done
ANSWER 3
Score 5
You can try to install MacPorts and install the renameutils
package:
renameutils @0.10.0 (sysutils)
renameutils is a set of programs designed to make renaming files faster and less cumbersome
ANSWER 4
Score 4
There are various version of rename. It looks like you are looking for the Perl-based one.
One version of this utility comes with the File::Rename Perl module. You can install it with something like sudo cpan -i File::Rename
.
Or, you could go with the rename from Debian's perl package. It is just a single file to download. Put it where ever you like and chmod it so that it is executable.
An alternative is the zmv tool that comes with zsh. It does not have the same syntax, but it does come with your OS and it can easily take care of many of the common cases.