[NTLUG:Discuss] True order of files in a directory.

Robert Thompson ntlug at thorshammer.org
Sat Aug 27 01:01:16 CDT 2005


Since everything in *nix is 'just a file', the directory file is what
has the "true" order to the files. If I have a directory /music/, then
the files that are under that directory are stored in the file /music.
Obviously /music is a special type of file (called a directory oddly
enough) that contains a list of other files under it. If I remember
correctly, the default order is creation time. I guess it just appends
the new file name to the end of the list. Other tools such as ls sort
the order into something that is more friendly.

Now since it's a special file, I have no clue on how to edit it the
correct way. It may be a bad idea since I don't know what happens if you
loose the mapping to where the file is. I'm not sure how the system
would pick it back up or if it would be a 'zombie' file. What I would
try as a test (insert all my disclaimers here :) ) is create a hard link
to a test directory, so there are two links to the directory (the
original file and the hard link). Then maybe create another hard link to
each test file in the directory. Then edit one of the two directory
files. Hopefully, if things get messed up, you still have a mapping to
the directory contents through the other directory file.

Robert Thompson


On Thu, 2005-08-25 at 21:45 -0700, Steve Baker wrote:
> Here's a puzzler.
> 
> My son has an el-cheapo USB MP3 player - it uses USB filing system
> for storing music tracks.  It allows you to put files into
> directories - so you can put tracks into albums and albums into
> collections by artist - and artists into collections by genre.
> 
> This all works.
> 
> However, he was puzzled that when he does an 'ls' of the gizmo
> from his Linux box, the order of the albums and tracks is
> alphabetical - but the order they appear to be when viewed on
> the MP3 player itself seems random.
> 
> Well - we all know that 'ls' (and most other Linux tools) sort
> file listings into alphabetical order.
> 
> The MP3 player evidently does not.  I can see the 'true' order
> of the files from Linux using 'ls -f' (which turns off sorting)
> and when I do that, Linux sees the same random ordering that
> the MP3 player does...so this is a good theory.
> 
> So - the question is, how can my kid get the albums (and more
> importantly, the tracks within the albums) into the right order
> on the MP3 player?
> 
> The obvious way is to wipe the USB drive clean and copy the files
> onto the player in the order they should be played in.
> 
> But this is a major pain to do because if you delete one song,
> the player will put the next song you create into that slot in
> the directory - resulting in horribly misplaced files.
> 
> What we *really* need is a tool to rearrange the order of files
> *physically* in the directory of the USB drive.
> 
> Does anyone have any insights into how to do this nicely?
> 
> ---------------------------- Steve Baker -------------------------
> HomeEmail: <sjbaker1 at airmail.net>    WorkEmail: <sjbaker at link.com>
> HomePage : http://www.sjbaker.org
> Projects : http://plib.sf.net    http://tuxaqfh.sf.net
>             http://tuxkart.sf.net http://prettypoly.sf.net
> -----BEGIN GEEK CODE BLOCK-----
> GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
> V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
> -----END GEEK CODE BLOCK-----
> 
> _______________________________________________
> https://ntlug.org/mailman/listinfo/discuss
> 





More information about the Discuss mailing list