Ended up writing a java program to do this... Won't post the code here because its quick, dirty and spaghetti ;) ... It is robust however and you can download the simple source code from www.nexle.dk/permanent-downloads/StackExchange/FileModChanger.java.zip to use modify, compile and use freely (but no warranty, check and test before you run).
What the tool does essentially is that it takes the last modified dates of files in one folder structure and applies it to files in another folder provided THAT;
- the file names and paths are the same (security)
- the file contents is the same (md5 check, again for safety)
- the date is not already the same for both files
I ran it against ~500,000 files and it seemed to work o.k.
Some notes;
- it only changes last modified date/time/timestamp so it should be safe
- the tool is default in "dry run" mode meaning it will show you what it would do, but not perform changes ('real' mode is activated by a command line argument 'real)
- It uses some code from the web (credit inside source file).
- It could be faster but its fast enough
- It has a cute little progress indicator while parsing through all the directories for files the first time ;)
Some code you might be able to draw inspiration from as well if you down want to trawl through the whole code;
How to change file modification date in Java;
File sourceFile = new File("/tmp/sourcefile");
File targetFile = new File("/tmp/targetfile");
long sourceDateModified = sourceFile.lastModified();
targetFile.setLastModified(sourceDateModified);
Hopefully someone else might be able to find it useful as well. Thanks for all the comments and hints though.
Usage and console output for the finished tool you can download (see above);
$ java -classpath . FileModChanger
USAGE (dry run, NO file changes made):
FileModChanger <source folder with original dates> <target folder with new/erased dates>
USAGE (real run,file date changes WILL be made):
FileModChanger <source folder with original dates> <target folder with new/erased dates> real
$ java -classpath . FileModChanger /Volumes/Untitled/D/knowledge/ISYS\ Desktop\ 6/ /Knowledge/ISYS\ Desktop\ 6/
Starting DRY run....
Starting DRY run....
Starting DRY run....
Starting to retrieve list of files (this may take a LONG time)...
0 folders processed
DONE creating the list of files, starting comparison...
About to operate on Volumes/Untitled/D/knowledge/IS[...]S Desktop 6/ISYSDesktop6Setup.exe:
SRC:Tue Jul 01 11:29:46 EST 2003 - bff684bfac4ed37e4a6b9a05ab625855 - Volumes/Untitled/D/knowledge/IS[...]S Desktop 6/ISYSDesktop6Setup.exe
TRG:Tue Dec 21 04:05:24 EST 2010 - bff684bfac4ed37e4a6b9a05ab625855 - /Knowledge/ISYS Desktop 6/ISYSDesktop6Setup.exe
DONE processing all files..
$ java -classpath . FileModChanger /Volumes/Untitled/D/knowledge/ISYS\ Desktop\ 6/ /Knowledge/ISYS\ Desktop\ 6/ real
Starting REAL run....
Starting REAL run....
Starting REAL run....
Starting to retrieve list of files (this may take a LONG time)...
0 folders processed
DONE creating the list of files, starting comparison...
About to operate on Volumes/Untitled/D/knowledge/IS[...]S Desktop 6/ISYSDesktop6Setup.exe:
SRC:Tue Jul 01 11:29:46 EST 2003 - bff684bfac4ed37e4a6b9a05ab625855 - Volumes/Untitled/D/knowledge/IS[...]S Desktop 6/ISYSDesktop6Setup.exe
TRG:Tue Dec 21 04:05:24 EST 2010 - bff684bfac4ed37e4a6b9a05ab625855 - /Knowledge/ISYS Desktop 6/ISYSDesktop6Setup.exe
RESULT:
- BEFORE: Tue Dec 21 04:05:24 EST 2010
- AFTER: Tue Jul 01 11:29:46 EST 2003
DONE processing all files..
also, you may need to increase Java's memory if you have lots of files and folders.
find
expression on a linux system to find differences between two file systems. I hadfind
print full file paths and attributes (if they were not folders, their sizes are pretty much useless), as well asexec
one of the checksum programs (md5sum
I think). I piped the output into files and diffed those. You could do that, then use the files determined this way as input for any copying script (either as inclusion or exclusion).rsync
can do that.