First up - I do not have any experience at all with programming in Android or Linux environments. So, very sorry if this question sounds stupid. Here is what I am looking for:
I use a USB drive in my car for music and I transfer files to this drive from my mobile using an OTG cable. There are around 600+ files in it and the music player in the car just randomly plays them. Problem is, since there are so many files, the player seldom plays the newly added ones.
Hence I was wondering if it would be possible to write a script for this - like a batch script or VBSript in Windows. When run, it would copy the latest 20 or so files, based on the date modified, to some folder, say "New". The script would be placed on the drive, preferably, and next time it is run, it would clear the existing folder and copy fresh files again.
Would this be possible?
Model: OnePlus One Android Version: 6.0.1 Cyanogen OS: 13.1.2
rm -f /target/*; cd /source; for music in $(ls -tr |head -n 20); do cp $music /target/; done
(quick raw hack: Delete all files in target directory, get the latest files in source (ls -tr
: sort by time descending) and copy the "top 20" (head -n 20
) files to the target directory; should work in Bash, but I've not tested it, just put together here in the comment box ;)