How can I batch move files to the same folder structure in a different location?

Joined
Feb 24, 2007
Messages
100
Reaction score
0
Points
16
Hi,

I recently had an issue with my iTunes Library so I used the Organize Library feature to have iTunes organise my library. What happened was that it put all of my music in a folder called 'Music' on my external hard drive, whereas previously it was not in a folder at all, e.g.

BEFORE: External Hard Drive / Abba / Greatest Hits / Mama Mia.m4a

AFTER: External Hard Drive / Music / Abba / Greatest Hits / Mama Mia.m4a

I don't have any particular issue with the updated folder structure, except that I had copies of the artwork for each album in my album folders, and these weren't moved when the audio files were moved/consolidated/organised. So I need to find a way of moving all of the artwork to the new folders, e.g.

External Hard Drive / Abba / Greatest Hits / folder.jpg

needs to become:

External Hard Drive / Music / Abba / Greatest Hits / folder.jpg

I have to do this for 3,000+ albums, and I have multiple artwork files for some albums, so I am hoping that there is a way of doing this using a batch/automated method of some kind, but I haven't been able to turn up anything yet.

Can someone help with this?

Thanks,

Nick
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,771
Reaction score
2,110
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
A shell script should be ale to do this. Let me try one out and I'll be back...

Is it safe to say that the only real change is that all the folders have been prefixed with "/Music"? If so, something like this would do the job.

Code:
for file in ‘ls *.jpg‘; do
echo "cp $file Music/$file"
done

Now this assumes you are doing this within the external hard drive directory. Usually /Volumes/<some name>...

For now, this script is just going to print what it's going to do, if it looks correct, you can remove the word "echo" and the double quotes and just leave the "cp" command.

This will
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top