Home » Questions » Computers [ Ask a new question ]

How to backup and restore only the file stamps (date & time) of many files within a folder at once?

How to backup and restore only the file stamps (date & time) of many files within a folder at once?

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.

Asked by: Guest | Views: 77
Total answers/comments: 1
Guest [Entry]

"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."