TL;DR - What happened here?
Given the OP’s scenario files can be renamed via the terminal with the following command sequence:
cat ./rename.csv | awk -F "," '{print "mv "$1" "$2}' | zsh
thecat
command outputs the content of a .csv-file with the old and new file names, one pair of names separated by comma per line.
this is passed using a pipe|
toawk
.-F ","
tells awk that the field seperator used in/from the .csv-file is a comma, and to output linewise mv followed by what ever is in the first ($1) and second ($2) column of the .csv-file.
finally this is passed using a pipe to the zshell (zsh
) which executes the awk output as a shell command sequence and ultimately moves a file matching the name in the first column of the .csv to a file named according to the second column.
😎
Thanks so much for all your help with this, this makes a lot of sense.
I've just tried to run the command again with my final CSV. I have a few files listed as things like 'File 1 (EU) [SOMETHING].jpg' in the 'final' name column (i.e. column 1). Now when I run the command I'm getting the following:
zsh: unknown file attribute:
zsh: unknown file attribute:
zsh: no matches found: (EU)
zsh: no matches found: (EU)
zsh: unknown file attribute:
zsh: unknown file attribute:
zsh: unknown file attribute:
zsh: unknown file attribute:
zsh: unknown file attribute:
zsh: unknown file attribute:
zsh: unknown file attribute:
zsh: unmatched "
Do I have to pass something to terminal to tell it to ignore characters such as '('?