Thursday, August 15, 2019

macos - Rename files and extensions in one command in Mac OS X



Is there a way to rename multiple files in one command. In Windows, I am aware of the command



ren *.* *.jpg



Is there a similar command in Mac OS X that i could run, instead of hitting enter on each and every individual file and doing the renaming.


Answer



With unix-like systems, it's easier to use find



find ./  


(try this first to make sure that your list of files looks like what you were expecting




find ./ -exec mv ${} ${}.jpg \; 


This will append .jpg to the end of every file found. The regex for changing the final extension, rather than just appending, is left as an exercise for the reader.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...