in reply to Maintaining date modified timestamp when copying files

Windows timestamps

Quoting myself from Re: Change create file date:

A quick search on CPAN reveals that Win32API::File::Time may be able to help you. From its synopsis:

use Win32API::File::Time qw{:win}; ($atime, $mtime, $ctime) = GetFileTime ($filename); SetFileTime ($filename, $atime, $mtime, $ctime);

(Unfortunately still untested.)

Update:

the timestamps, at the moment, are one of the key ways that I’m keeping track of the large amount of data I’ve got

Actually, as you're discovering yourself, this is dangerous, I'd strongly recommend you don't rely on the filesystem to keep track of that information, at the very least store the date/time information in a separate simple text file. Update 2: The following will take the list of files in the current directory (excluding those beginning with a dot) and output a tab-separated list of filename, ctime, mtime, and atime (if available). You can change the glob expression "*" to match specific files if you like.

perl -MFile::Glob=bsd_glob -le '$,=qq(\t);print$_,(stat)[10,9,8]for bs +d_glob(q(*))'

(You may need to change the quotes, I'm not on Windows at the moment.)

Replies are listed 'Best First'.
Re^2: Maintaining date modified timestamp when copying files (updated x2)
by Maire (Scribe) on Oct 31, 2017 at 09:16 UTC
    Thanks for your help! I've installed the module, and I'm just playing about with it now to see if I can get it to work on my data. I will edit my post to verify the solution if I have any success. And thank you so much for the script to back-up the metadata for my work! I'd tried creating something similar myself, but I wasn't using the glob function and was thus not having much luck.