Mac os x shell script rename files
- Mac os x shell script rename files how to#
- Mac os x shell script rename files mac os#
- Mac os x shell script rename files code#
# (this renames all *.PNG files to *.png (effectively changing the case # (this renames all *.htm files to *.html) # Purpose: move all the files with the first filename extension # Name: mmv (a unix/linux "multiple move" script) You'll have to manually remove that comment to get the actual move command to work, and I suggest only doing that after you run this script at least once with just the "echo" output. Note that the "mv" command is commented-out by default. To run it, just save this text to a file named mmv on your Unix/Linux system, make sure that file is in your PATH, and make it executable ( chmod +x mmv), and then give it a spin.
Mac os x shell script rename files code#
Here's the source code for my mmv shell script.
That being said, automating a Unix/Linux mv command like this is still a dangerous thing to do, so please make a backup copy of your data to another folder before using this script. I also re-tested my PNG and HTML examples above, and they worked fine as well. Moving "Bam Boom.txt" -> "Bam Boom.text". To test this new script, I created three filenames with spaces in them, like this:Īnd in doing so, I saw the following output, and the filenames with spaces were renamed properly:
Mac os x shell script rename files how to#
I personally never create filenames with spaces in them, but when I wrote a script to convert CAF files to AIF files (AIFF, AIFC, WAV, MP3, etc.), I had to figure out how to deal with filenames that have spaces. Filenames with spacesĪfter the first comment on this article (shown below), I just re-wrote this script to deal with filenames that have spaces in them. Any "move" operation is dangerous, let alone an automated move operation. That being said, please read all the warnings and cautions carefully. JPG to be more specific:įor a small directory with just three matching files, the output from the mmv script will look something like this:Īs you can see, this script can be a great time saver. Here's the command I would invoke to rename every file in the current directory that currently ends with the extension JPG, or.
It's usage is very simple, you just specify the current file extension, and the new desired file extension, and it will move every file that matches the current file extension to the new extension. Hopefully you'll like this Unix shell script that I've named mmv, for multiple move. Sure, you can change all these filenames manually, but hey, this is Unix, there must be a better way, right? Usage I kept running into a combination of problems, including file extensions ending in uppercase characters, to files named *.htm that I wanted to renamed to *.html. Many years ago I created a Unix shell script to solve just this problem. In particular, you'd like to be able to change the extensions of a large number of files, such as from *.JPG to *.jpg (changing the case of each file extension from upper case to lower case).
Mac os x shell script rename files mac os#
You're on a Mac OS X, Unix, or Linux system, and you'd like to be able to rename a large number of files at once. Summary: A Unix/Linux shell script that can be used to rename multiple files (many files) with one shell script command.