rscott5
May 22nd, 2007, 04:46 AM
Hi all,
I'm very new to Linux and any scripting language (I do have a good programming background though), so please bare with me, here goes. I have a huge collection of music, all in different file formats, which I need to separate out in order to convert. The thing is that I want to maintain my file structure when I separate out the certain files to be converted. I have my music set up in a /Artist/Album/Number - Song Title format. Here is the code that I tried to use to accomplish my task:
cp /home/ryan/music/*/*/*.m4a /home/ryan/tobeconverted/*/*/*.m4a The problem here (I think) is that the cp command doesn't create the new .../*/*/ (.../Artist/Album/) directories when it needs to so when I run this it says directory does not exist. So my first question, is there a way to make the cp command do this for me?
If not, I suppose I will have to write a script to do this. The best way that I can think of to do this would be to loop through the folders, and if a *.m4a file is found, then it should create the appropriate directories (if needed) and then copy the file. Does this sound right? Any pointers as to how I would do this in Perl, or any other language?
Thanks in advance for your help.
Ryan
I'm very new to Linux and any scripting language (I do have a good programming background though), so please bare with me, here goes. I have a huge collection of music, all in different file formats, which I need to separate out in order to convert. The thing is that I want to maintain my file structure when I separate out the certain files to be converted. I have my music set up in a /Artist/Album/Number - Song Title format. Here is the code that I tried to use to accomplish my task:
cp /home/ryan/music/*/*/*.m4a /home/ryan/tobeconverted/*/*/*.m4a The problem here (I think) is that the cp command doesn't create the new .../*/*/ (.../Artist/Album/) directories when it needs to so when I run this it says directory does not exist. So my first question, is there a way to make the cp command do this for me?
If not, I suppose I will have to write a script to do this. The best way that I can think of to do this would be to loop through the folders, and if a *.m4a file is found, then it should create the appropriate directories (if needed) and then copy the file. Does this sound right? Any pointers as to how I would do this in Perl, or any other language?
Thanks in advance for your help.
Ryan