Using bash to copy file to spec folders

Posted by Franko on Stack Overflow See other posts from Stack Overflow or by Franko
Published on 2011-11-16T20:25:09Z Indexed on 2011/11/19 9:50 UTC
Read the original article Hit count: 245

Filed under:
|
|

I have a folder with a fair amount of subfolders. In some of the subfolders do I have a folder.jpg picture. What I try to do find that folder(s) and copy it to all other subfolders that got the same artist and album information then continue on to the next album etc.

The structure of all the folders are "artist - year - album - [encoding information]". I have made a really simple one liner that find the folders that got the file but there am I stuck.

ls -F | grep / | while read folders;do find "$folders" -name folder.jpg; done

Anyone have any good tip or ideas how to solve this or pointers how to proceed?

Edit:

First of all, i´m real new to this (like you cant tell) so please have patience.

Ok, let me break it down even more.

I have a folder structure that looks like this:

artist1 - year - album - [flac]
artist1 - year - album - [mp3]
artist1 - year - album - [AAC]
artist2 - year - album - [flac]
etc

I like to loop over the set of folders that have the same artist and album information and look for a folder.jpg file. When I find that file do I like to copy it to all of the other folders in the same set.

Ex if I find one folder.jpg in artist1 - year - album - [flac] folder do I like to have that folder.jpg copied to artist1 - year - album - [mp3] & artist1 - year - album - [AAC] but not to artist2 - year - album - [flac].

The continue the loop until all the sets been processed. I really hope that makes it a bit more easy to understand what I try to do :)

© Stack Overflow or respective owner

Related posts about linux

Related posts about bash