Ubuntu mp3 sync script help needed
June 23, 2016 5:23 PM   Subscribe

I am looking at writing a script for my Ubuntu system that synchronizes the latest (as in, last added) N (say, 10 or 20) files from one of my home folders with one of my Dropbox folders. Rsync seems to offer all but one needed feature.

Basically I want to be able to listen to my newest favorite tunes wherever I go. And that music is always an mp3 file or mp4 file in the source folder.

Rsync seems to handle everything except the "limit it to 10-20 files" part. How can I do that? Thanks!
posted by circular to Computers & Internet (3 answers total)
 
Are you using ZSH? If so, glob modifiers should have you covered. Stack Overflow reference
rsync -a -- /path/to/directory/*(.om[1,10]) remote-server:

posted by CrystalDave at 5:42 PM on June 23, 2016 [1 favorite]


Best answer: Something like:
ls -t | head -n 10 | rsync --from0 --files-from - ./ dest
should do it. Here is the man page for rsync.
posted by hoyland at 5:43 PM on June 23, 2016 [1 favorite]


Response by poster: > Are you using ZSH?

Nope. Maybe I should though! :-) That modifier looks super convenient.

> Something like...

Thank you! I think that got me far enough. I ended up with this example version working:
ls -t1 ./*.mp3 | head -n 15 | rsync --files-from=- ./ ~/tmp/soundtmp/
I'll customize it from there!
posted by circular at 6:27 PM on June 23, 2016


« Older My music tastes are stuck in 2004. Find me new...   |   They don't ask, so I don't tell Newer »
This thread is closed to new comments.