Batch re-name files with CSV - Catalina

I'm trying to take a number of jpg files and batch change their names from their existing name to a specific name.


I have an xls I've converted to csv. it has the existing name in column A and the required name in column B. extensions would not change, only the file name.


if all files (jpgs and csv) are in the same folder, what steps do I need to follow in order to have this task automated?


I have experience using InDesign w/ csv's for automation but little experience w/ code.

I'm assuming I would use automator but if there's a terminal command that's just as good, more straightforward the better.

Posted on Jan 3, 2023 12:27 PM

Reply
1 reply

Jan 3, 2023 6:52 PM in response to GuiPizza

This bash script may do what you want.

First, copy the files to rename (or a few of them), to another Folder to Test


The csv file I tested on was:

/Users/Tony/Desktop/file1.txt,/Users/Tony/Desktop/file2.txt
/Users/Tony/Desktop/file3.txt,/Users/Tony/Desktop/file4.txt


and the bash script is:

#!/bin/bash

while read f
do
	c1=${f%,*}
	c2=${f#*,}
	mv "$c1" "$c2"
done < /Users/Tony/Desktop/Book1.csv


Test of copies of the files



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Batch re-name files with CSV - Catalina

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.