ericramos1990 wrote:Hey guys!
I have a question regarding a script I have to copy all of my music to my phone.
Code: Select all
cp -ruv /home/eric/music/* '/media/MyAndroid/Internal storage/music'
However, there is one additional thing I want to do.
If I delete some songs from my computer, how can I get this script to simply delete them from my phone as well?
Use rsync with --delete option. Anything NOT found in /home/eric/music will be deleted from "Internal storage/music.
Code: Select all
rsync -avz /home/eric/music "/media/MyAndroid/Internal storage" --no-perms --delete
do a test...
now rsync it with
Code: Select all
rsync -avz /home/eric/music "/media/MyAndroid/Internal storage" --no-perms
one of the very first files shown to be copied should be
Code: Select all
sending incremental file list
./
myfake,mp3
Now check for it with:
Code: Select all
find `pwd` "/media/MyAndroid/Internal storage" -name myfake.mp3 -type f
and that should spit out
Code: Select all
/media/MyAndroid/Internal storage/music/myfake.mp3
Now we are cooking with gas so, now delete the /home/eric/music/myfake.mp3 and use this from now on:
Code: Select all
rsync -avz /home/eric/music "/media/MyAndroid/Internal storage" --no-perms --delete
and everything NOT present in /home/eric/music will NOT be present in /media/MyAndroid/Internal storage after doing so.
adding an n to -avz (-avzn) will do a "dry-run".
so try that too before committing to using the --delete option of rysnc.
If you get nervous or stuck,. shoot me a PM and we'll go over it.