Change file creation time on a FAT filesystem

fatfilesfilesystemsstat

I need a way to change the creation time of a file on a mounted FAT32 volume. I have to do that because my MP3 player will only read files sorted by this creation time.

If I can find a way to set the file creation time (like touch can do with modification / access time) of a file, a trivial script will allow MP3 files to be read in the right order (as expected, alphabetically).

But I've yet to find a solution, and my searches have been in vain. I hope you guys can help me !

Best Answer

First thing that comes to mind is to mv the file(s) to a temporary, cp the temporary file to the old filename and delete the temporary.

I just made a fast check:

touch foo
ls -l foo

returns:

0 -rw-r--r-- 1 shunz shunz 0 2011-03-22 11:07 foo

wait some minutes and then:

mv foo bar
ls -l bar

0 -rw-r--r-- 1 shunz shunz 0 2011-03-22 11:07 bar

notice the creation time isn't modified, while:

cp bar foo
ls -l foo bar

0 -rw-r--r-- 1 shunz shunz 0 2011-03-22 11:07 bar
0 -rw-r--r-- 1 shunz shunz 0 2011-03-22 11:10 foo

now foo is created at current time!

EDIT

sorry, forgot to mention, tried this on a FAT32 formatted USB stick under Ubuntu.

Related Question