LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash script to copy all music to new hard drive from multiple network shares. (https://www.linuxquestions.org/questions/programming-9/bash-script-to-copy-all-music-to-new-hard-drive-from-multiple-network-shares-825214/)

pobrika 08-09-2010 10:45 PM

Bash script to copy all music to new hard drive from multiple network shares.
 
Hi guys,

I need a script to copy music from a network drive to my local disk.

I require the script to auto mount the remote server, then to create the directory path to the mp3's

I have a list of all teh songs in the following format, note some have spaces.

\\7800SPARE4\Users\Public\Music\Sample Music\Kalimba.mp3 \\7800SPARE4\Users\Public\Music\Sample Music\Maid with the Flaxen Hair.mp3 \\7800SPARE5\Users\Public\Music\Sample Song \Sleep Away.mp3

I can use the following to mount the directory:
mount -t cifs //7800SPARE4/Users /dest-o username=user,password=pass

I'm thinking the best way would be to get the share name 7800SPARE and the grep for all these in the list, then mount it and do a while read LINE
However I would need to creat the folders, I am unsure on how to do this. I think I would need to sed the backslashes to forward ones and then use rsync? Then unmount and move on to the next ones, if I can't mount the share It would be nice to log it and skip it.

If anyone has a script for this it would be great.

Thanks

yooy 08-09-2010 11:45 PM

hm,
you can search for mp3 with find (filetype) and than "cp"
on first search grep directories names and create them on local disk
on second search actualy copy files.

konsolebox 08-09-2010 11:56 PM

You can use this script that I posted before to copy files that end in .mp3.
http://www.linuxquestions.org/questi...0/#post3895402


All times are GMT -5. The time now is 03:46 PM.