Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Keith-Jaw

macrumors newbie
Original poster
Aug 11, 2015
7
0
I need to add a suffix to a whole load of files, to make them useable, but it's a pain doing this one at a time.

At one time I knew how to create a batch file in MS-DOS. Something like: name *.* as *.gsm

Is there a similar technique for OS-X. If so, how to run it?
 
Code:
man find

Examples

Code:
# change all *.doc files in current dir, non-recursively, to *.txt
find . -maxdepth 1 -type f -name "*.doc" -exec bash -c 'mv "$0" "${0%\.doc}.txt"' {} \;

# add .txt extension to all files in current dir, non-recursively
find . -maxdepth 1 -type f "*.txt" -exec bash -c 'mv "$0" "${0}.txt"' {} \;
 
Code:
man find

Examples

Code:
# change all *.doc files in current dir, non-recursively, to *.txt
find . -maxdepth 1 -type f -name "*.doc" -exec bash -c 'mv "$0" "${0%\.doc}.txt"' {} \;

# add .txt extension to all files in current dir, non-recursively
find . -maxdepth 1 -type f "*.txt" -exec bash -c 'mv "$0" "${0}.txt"' {} \;

Thanks - but I need a bit more:

After I've generated the script file, how do I run it? Is there something like a DOS window?
How do I 'log on' to the current dir, so that the system knows what the current directory is?
 
I need to add a suffix to a whole load of files, to make them useable, but it's a pain doing this one at a time.
At one time I knew how to create a batch file in MS-DOS. Something like: name *.* as *.gsm
Is there a similar technique for OS-X. If so, how to run it?
It's not a script and it's not a free app ($19.95), but I like "A Better Finder Rename" app.
Here is a link to the site:
http://www.publicspace.net/ABetterFinderRename/
 
Thanks - but I need a bit more:

After I've generated the script file, how do I run it? Is there something like a DOS window?
How do I 'log on' to the current dir, so that the system knows what the current directory is?

  • From your web browser copy the text for the script.
  • Open the terminal application in the Applications/Utilites folder.
  • In the terminal app window enter:
    • vi <name to call script>.sh
    • Press i-keyboard key.
    • Press Alt-v keyboard keys.
    • Press ZZ keyboard keys. Make sure both letters are uppercase Z.
  • In the terminal app window enter:
    • chmod 755 <name that you called the script>.sh
  • To run the script, enter the following in the terminal app window.
    • ./<name that you called the script>.sh
That is how you create the script which will reside in your user account root directory. So let's say that you want to create the script called renamefiles.sh and the folder where the files reside in your user account named Documents.
  • From your web browser copy the text for the script.
  • Open the terminal application in the Applications/Utilites folder.
  • In the terminal app window enter:
    • cd ~/Documents
    • vi renamefiles.sh
    • Press i-keyboard key.
    • Press Alt-v keyboard keys.
    • Press ZZ keyboard keys. Make sure both letters are uppercase Z.
  • In the terminal app window enter:
    • chmod 755 renamefiles.sh
  • To run the script, enter the following in the terminal app window.
    • ./renamefiles.sh
 
It's not a script and it's not a free app ($19.95), but I like "A Better Finder Rename" app.
Here is a link to the site:
http://www.publicspace.net/ABetterFinderRename/

I like NameChanger a free program that has a prepend and append to add to the beginning or end of a file name along with many other renaming options. Have used it for years without problems and the best part as already mentioned it is free.

http://mrrsoftware.com/namechanger/

Another one is name mangler which I use for its droplet function where I drag and drop onto a droplet to clean out the garbage special characters and spaces from file names. I do believe they have went to a paid model though in the later versions of it, last free version I have installed still does the trick though.

http://manytricks.com/namemangler/

Edit2: Now I think about it more not sure the NM does an append function though a replace of current extension with a current extension plus new would work with it.
 
Last edited:
Another option occurs to me. These files are on a network, and another MAC on that network has parallels. So maybe it would be simpler to create and run a batch file in good old DOS. If I can remember the syntax!

Alternatively, these other programs might do the trick.

Many thanks for all your suggestions, guys.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.