Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to retag all my music collection (MP3, OGG, etc) with replaygain info, but I don't want them to lose their original file timestamp as sometimes I want to know when I added a file to my collection as it helps me find them by sorting them in my favorite file manager by date.

So here is my question: Is there a tool (or a commmand that I can use in a batch file) that I can use to batch-backup only the timestamps of all the files, before I do the retagging and then to be able later to restore their file timestamps back? If it can be done recursively to all folders beneath, it will be extra nice!

share|improve this question
    
on what operating system? –  John T Nov 27 '09 at 9:57
    
Sorry about that, Windows 7 x64. –  Saxtus Nov 27 '09 at 16:15
1  
couldn't you just change the date/time column to show create time, not last modified time? in winXP you can right-click on the column name in the standard file manager and select the "Date Created" column to get that data. more featureful file managers probably include this capability as well. –  quack quixote Dec 2 '09 at 12:45

1 Answer 1

up vote 2 down vote accepted

Assuming you use Windows, you could do it with TakeCommand Console LE.

To backup the timestamps, use the following command:

pdir /(fpn"|"dy/m/d"|"th:m:s) /s /a:-d * >c:\flist.txt

This will create a file (here c:\flist.txt) containing the file names (including paths) and their date (in y/m/d format) and time (in h:m:s format). The /s makes it recursive, so it will pick up files in sub-directories.

To avoid problems with space in directories and names, this version of the command uses the "|" sign as delimiter for the fields.

Sample file produced by the command above:

[C:\Test]type c:\flist.txt
C:\Downloaded Files\JPSoft\TCCLE10\English.dll|2009/08/29|13:11:36
C:\Downloaded Files\JPSoft\TCCLE10\French.dll|2009/08/29|13:11:38
C:\Downloaded Files\JPSoft\TCCLE10\German.dll|2009/08/29|13:11:38
C:\Downloaded Files\JPSoft\TCCLE10\license.txt|2009/01/25|20:09:04
...

To restore, use the command:

for /f "tokens=1,2,3 delims=|" %a in (@c:\flist.txt) do touch /d%b /t%c "%a"

This command will parse the file stored above and run several touch commands, setting back the saved dates and times to the files. The "|" sign is indicated as being the delimiter for the fields.

share|improve this answer
    
During restore I get multiple errors like the following and nothing gets restored: "I:\Media\Audio\MP3\EAGLES~1.MP3" TCC: (Sys) The system cannot find the file specified. although in the flist.txt file the record of the file exists as: I:\Media\Audio\MP3\EAGLES~1.MP3 1998/06/07 21:51:20 What am I doing wrong? Pre-thanx. –  Saxtus Dec 2 '09 at 10:30
1  
Difficult to say. It worked fine for me. Maybe it's linked to the use of short filenames (with the ~1) to avoid problems with spaces in the directories and filenames. I changed both commands so they can cope with long filenames, including spaces, by using "@" as a delimiter (instead of spaces by default). –  Snark Dec 2 '09 at 11:16
    
It worked when I used "|" instead of "@" as delimiter (as some of my filenames already had "@" in them -- it is an allowed character anyway, unlike "|"). You may want to update your answer with the new delimiter, so I can set it as accepted answer. Thank you! –  Saxtus Dec 3 '09 at 0:36
    
Changed! Thanks. –  Snark Dec 3 '09 at 6:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.