Move certain files into different directories : BASH or CSH
Hi Crew,
I have a situation where I have mulitple files in /audio/projectname/44100/ of various bit depths. ie 44100, 22050, 11020 etc. and I need to move them into their respective folder (which may need to be created) ie, /audio/projectname/44100/ /audio/projectname/22050/ /audio/projectname/11020/ the filenames look like radio_file_44100.wav radio_file_22050.wav radio_file_11020.wav As the directy has not already been vreated it's hard to do any matching, also these names sometimes change so radio_file_44100.wav might be radio_file_part1_1.wav and so on. i don't know enough about sc ripting to do this in any 'quick' way. any help would be rad! cheers in advance, mw |
to move them into folders:
ls *.wav | while read a; do n=`echo $a | sed s/radio_file_// | sed s/.wav//` echo mv $a /audio/projectname/$n done output: mv radio_file_11020.wav /audio/projectname/11020 mv radio_file_22050.wav /audio/projectname/22050 mv radio_file_44100.wav /audio/projectname/44100 making the folders is just a minor mod of the above code |
thanks for the quick reply. the above didn't actually work, it did print the command but it didn't action it. But if I did them individually it would. BUT that's not quite what I'm searching for..
'radio-file' needs to be extracted from the file name beacuse it could be any name, it could read delay_v01_01.wav or phase_v02_06.wav and they need to be mv'd into their correct folders. am I any clearer? thanks agian for you help. cheers, mw |
Hi
Code:
ls -1 *.wav | while read a; do |
Excellent. Almost there..
here's an actual file name. radio403_00_delay_v01.0001.wav, radio403_00_delay_v01.0002.wav, radio403_00_delay_v01.0003.wav radio403_00_phase_v01.0001.wav, radio403_00_phase_v01.0002.wav, radio403_00_phase_v01.0003.wav so delay1-3 goes into /audio/projectname/delay and phase 1-3 goes into /audio/projectname/phase thanks again... mw |
And here's one that will use the actual sample rate like "22050" or "11025", even when the sample rate is not part of file name. It will read the sample rate from the file itself.
So a file called "radio403_00_delay_v01.0001.wav" will be moved to the sub-directory "22050" if it has a sample rate of 22050. Is this what you are looking for? Code:
#!/bin/bash |
WOW, thats cool. although the previous one could be applied to images or vid sequences as well.
many thanks, it's been an interesting day ... mw. |
All times are GMT -5. The time now is 03:27 PM. |