#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    22
    Rep Power
    0

    Smile Audio file ordering in flash drive


    There are various mp3/wma players in China using SD/TF cards as the storage. The audio files can be selected by the order of them been copied to the flash drive no matter what's the full file path. (enter 8 or 08 or 008 or ... will load the 8th audio file been copied or moved into the flash drive)

    My questions are:
    (1) What's the file attribute determines the order above?
    (2) Is there a Perl script can reset the total linear order according to the file name (dictionary order of the files, ignoring the file path order), assuming there is no duplicated file name?
    (3) Roughly speaking, how difficult to write such a script?

    Thanks for your help!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    832
    Rep Power
    496
    If you use the Perl sort function, this will default to lexicographical order (i.e. more or less what you call dictionnary order), it is fairly easy to produce a list of file in the order you are looking for. But I don't know enough about what you want to do exactly to figure out how easy the rest will be. If the idea is just to copy the files in a given order, then it should be quite easy.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    1
    Rep Power
    0
    Originally Posted by elimqiu
    There are various mp3/wma players in China using SD/TF cards as the storage. The audio files can be selected by the order of them been copied to the flash drive no matter what's the full file path. (enter 8 or 08 or 008 or ... will load the 8th audio file been copied or moved into the flash drive)

    My questions are:
    (1) What's the file attribute determines the order above?
    (2) Is there a Perl script can reset the total linear order according to the file name (dictionary order of the files, ignoring the file path order), assuming there is no duplicated file name?
    (3) Roughly speaking, how difficult to write such a script?

    Thanks for your help!
    I have the same problem in your 1st questions
  6. #4
  7. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,259
    Rep Power
    1810
    I did a google search and there are a lot of free utility programs that will do this for these devices already.

    Here's a writeup from one :
    I bought a cheap car stereo about a year ago that plays MP3 files from either CD or from a USB flash drive or a compact flash memory card. However, it plays them in the order that they were added to the device.

    Sometimes, Windows doesn't copy the files over in the right order, or if files are added at a later date, they stay at the end. When I listen to full albums in the car, it bugs me when they play out of order.

    I searched around for a utility to correct the problem, but none of them supported recursion of subfolders. So I decided to make one.

    Why it is necessary

    The FAT file system doesn't support sorting directory entries. However, this is the only file system for USB flash drives that is widely supported. Unless the hardware or software accessing the device (like your computer) resorts them for display, the files will show in the order they were added to the directory.

    How we get around it

    To get around the problem, we cheat. By making a temporary directory, moving all the files to it, and then moving them back, in the new order, we effectively resort the directory. We then repeat the process in each directory listed. Sorter does this in reverse order, but not for any reason other than it makes the progress bar more accurate, because it knows how many files are there before it starts.
    I'm sure the same thing could be easily replicated in perl, but I don't have a device to test.
    Last edited by keath; February 26th, 2014 at 11:36 AM.

IMN logo majestic logo threadwatch logo seochat tools logo