How to write files in specific order?

Posted by Bernie on Super User See other posts from Super User or by Bernie
Published on 2014-05-29T02:15:47Z Indexed on 2014/05/29 3:33 UTC
Read the original article Hit count: 528

Filed under:
|
|

Okay, here's a weird problem -- My wife just bought a 2014 Nissan Altima. So, I took her iTunes library and converted the .m4a files to .mp3, since the car audio system only supports .mp3 and .wma. So far so good. Then I copied the files to a DOS FAT-32 formatted USB thumb drive, and connected the drive to the car's USB port, only to find all of the tracks were out of sequence. All tracks begin with a two digit numeric prefix, i.e., 01, 02, 03, etc. So you would think they would be in order. So I called Nissan Connect support and the rep told me that there is a known problem with reading files in the correct order. He said the files are read in the same order they are written. So, I manually copied a few albums with the tracks in a predetermined order, and sure enough he was correct.

So I copied about 6 albums for testing, then changed to the top level directory and did a "find . >music.txt". Then I passed this file to rsync like this:

rsync -av --files-from=music.txt . ../Marys\ Music\ Sequenced/

The files looked like they were copied in order, but when I listed the files in order of modified time, they were in the same sequence as the original files:

../Marys Music Sequenced/Air Supply/Air Supply Greatest Hits> ls -1rt 01 Lost In Love.mp3 04 Every Woman In The World.mp3 03 Chances.mp3 02 All Out Of Love.mp3 06 Here I Am (Just When I Thought I Was Over You).mp3 05 The One That You Love.mp3 08 I Want To Give It All.mp3 07 Sweet Dreams.mp3 11 Young Love.mp3

So the question is, how can I copy files listed in a file named music.txt, and copy them to a destination, and ensure the modification times are in the same sequence as the files are listed?

© Super User or respective owner

Related posts about file

Related posts about rsync