Batch set file's date/time from other files (name matching)

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
lupida
Junior Member
Junior Member
Posts: 15
Joined: 2008-06-02, 17:31 UTC

Batch set file's date/time from other files (name matching)

Post by *lupida »

I have a rather specific challenge in setting many files' datetime by reading other file's timestamps. Let me explain my use case with an example.

I have a reasonable amout of WAVE files blowing up my backups. I want to compress/encode them to MP3 or another audio format of choice (and the delete the originals). The encoder, of course, sets the filedate of the encoded file to now(). But I would like to keep the filedate of the original WAVE file.

A valid, but not optimal solution would be to first batch rename those WAVE files, prefixing the filename with something like 2018-10-17_18-30-00_filename.ext and only then start the batch encode. Since most encoders can reuse the original filename - problem solved in conserving the WAVE file's creation/modification date.

But I am wondering if I could set the filedate in batch by reading another file's datetime with the same filename but different extension, located in the same folder. Talking about backups and archiving, I am aware this is sort of lying in terms of a file's "real" modification/creation datetime, but on the other hand, I see no reason why not.

Has anybody faced this yet or am I the only pedant?

Lupida
User avatar
Gral
Power Member
Power Member
Posts: 1460
Joined: 2005-01-26, 15:12 UTC

Re: Batch set file's date/time from other files (name matching)

Post by *Gral »

Using only Total Commander you can do it like this

Move all source files to another directory with a meaningful name. e.g. "To be deleted"
Rename all these files to names of new encoded files e.g. wav -> mp3 using "Multi rename tool" (yes, now WAVE files have wrong extension but it's not matter as you plan to delete these files soon).
Invoke "Synchronise Dirs" from "Commands" menu
Uncheck "subdirs" "by contents" "empty directories", disable "singles"
Press "Compare"
When completed, select all files and press right mouse button, choose one of "Copy files properties..." command.
Check "timestamp", uncheck other options.
Press "OK"
Now you can delete source files.
lupida
Junior Member
Junior Member
Posts: 15
Joined: 2008-06-02, 17:31 UTC

Re: Batch set file's date/time from other files (name matching)

Post by *lupida »

How cool is that! I never realized that option in the sync dialog, although I am using it quite often.
This works perfectly. And it feels quite straightforward, too.
Thank you very much for this!
Post Reply