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

NewUsername

macrumors 6502a
Original poster
Aug 20, 2019
581
1,273
I want to be able to bulk rename files according to a text file. Right now, I still need to use Windows for that, where I use Bulk Rename Utility.

So the idea is as follows: I have OrigName1.ext and OrigName2.ext in a folder and I want to rename them to NewName1.ext and NewName2.ext. For Bulk Rename Utility I can make a text file like this:

OrigName1.ext|NewName1.ext
OrigName2.ext|NewName2.ext

Afterwards, I import this text file in Bulk Rename Utility and do all the renaming in one click.

Is there a Mac application that does the same thing?
 

Slartibart

macrumors 68030
Aug 19, 2020
2,902
2,608
make a backup of your files.

open a terminal window.

check wether you made a backup of your files.

Run in the terminal the following command:

#!/usr/bin/env bash cd /patch/to/your/files while read -r line; do mv $line done < /path/to/list-with-old-and-new-names.txt

the file list-with-old-and-new-names.txt is a plain text file which contains the names:

new1 old1 new2 old2 new3 old3 usw.

EDIT: long shift… I might have missread the OP completely. If the new-name-part/pattern is for all selected files the same, you can just use the finder as @chabig suggests.
 
Last edited:

chabig

macrumors G4
Sep 6, 2002
11,281
8,985
I`m surely misunderstanding something, but can't you do that already in Finder?
If it as described in the original post, this is easy in the Finder. Select the files, right click, and choose “rename”.
 

NewUsername

macrumors 6502a
Original poster
Aug 20, 2019
581
1,273
make a backup of your files.

open a terminal window.

check wether you made a backup of your files.

Run in the terminal the following command:

#!/usr/bin/env bash cd /patch/to/your/files while read -r line; do mv $line done < /path/to/list-with-old-and-new-names.txt

the file list-with-old-and-new-names.txt is a plain text file which contains the names:

new1 old1 new2 old2 new3 old3 usw.

EDIT: long shift… I might have missread the OP completely. If the new-name-part/pattern is for all selected files the same, you can just use the finder as @chabig suggests.
Thanks, this is exactly what I was looking for! However, when I try it out it doesn’t seem to work…
 

Slartibart

macrumors 68030
Aug 19, 2020
2,902
2,608
Thanks, this is exactly what I was looking for! However, when I try it out it doesn’t seem to work…
please remove the shebang line and execute line by line in the terminal:

cd /path/to/your/files/ while read -r line; do mv $line done < /path/to/list-with-old-and-new-names.txt

just saw that the order of names is different in your file, so:

cd /path/to/your/files/ while read -r line; do mv $(awk '{print $2, $1}' <<<$line) done < /path/to/yourfilenamelist.txt.txt

EDIT: make sure that the file with the old and new filenames is a plain text file, only a single tab seperated newname from oldname in this file, filenames do not include spaces.
 
Last edited:

NewUsername

macrumors 6502a
Original poster
Aug 20, 2019
581
1,273
please remove the shebang line and execute line by line in the terminal:

cd /path/to/your/files/ while read -r line; do mv $line done < /path/to/list-with-old-and-new-names.txt

just saw that the order of names is different in your file, so:

cd /path/to/your/files/ while read -r line; do mv $(awk '{print $2, $1}' <<<$line) done < /path/to/yourfilenamelist.txt.txt

EDIT: make sure that the file with the old and new filenames is a plain text file, only a single tab seperated newname from oldname in this file, filenames do not include spaces.
Thanks a lot, this works perfectly!!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.