3

I'm trying to copy some files to a folder where there are already older versions of those files with the robocopy tool. And in order to differentiate versions, I'd like to set the timestamp to "now" in the output folder when the file is copied over.

Basically it would be like copying and "touch"-ing the file.

However, as easy as it looks, it seems that there is no option to do that. I understood that when using the D (data) flag on /COPY, the T (timestamp) flag is automatically added, so the source timestamp is kept.

Is there something I missed in the options? Or is there any other alternative?

Thanks for any help.

Julien.

  • Your wanting something akin to just a GUI copy/paste then? Do you care that the entire structure is copied every time or do you want just the changed files (like robocopy does)? – TheCleaner Dec 9 '13 at 16:24
  • I just need new files to be copied. This is needed because they are JAR files that are loaded in order to be deployer with Java Web Start. If the jar is older, then Java Web Start will not download it... – foch Dec 9 '13 at 16:44
1

I don't think Robocopy will work for this. A core part of how Robocopy works is by comparing timestamps and file sizes in the source and destination folders to determine which files need to be copied. So, you can't use Robocopy to update timestamps in the destination to be 'newer' than the timestamps on the source.

Now, I have seen this behavior when pushing files with UNIX permissions to NTFS (or vice versa) but it's not so much an intended behavior as the inability of Robocopy to translate ACLs.

I'm not exactly clear on what you're trying to do, but there's probably quite a few workarounds to get something that works for you. Examples:

  • Have the robocopy script copy files into a directory named based off the date.
  • Capture the time/date to a log file whenever the script runs successfully.
1

You'd have to update the file(s) after the robocopy is finished.

You'd have to use something like:

If you want to assign the current time and date to a file without modifying the file, use the following syntax:

copy /b filename.txt +,,

The commas indicate the omission of the Destination parameter.

You have to run this in the destination folder, meaning you have to be in this folder in a command line to have it work correctly.

You could write a batch file that would run this command on certain files in this destination folder.

But I really still don't get your latest comment "I just need new files to be copied." -- that's what robocopy does and will grab the new timestamp of the new/updated source files when it copies. So any new JAR files in the source should have new timestamps in both the source and the destination.

  • Well this would work, the thing is I'd like to apply it only to files that were copied by robocopy. And apart from parsing robocopy's result I don't believe there's an easy way to know which files were overriden! – foch Dec 10 '13 at 20:16
  • @foch - I'm still a little confused though. Read my last "paragraph". How do the updated JAR files (which get copied by robocopy because the source has changed) not have updated timestamps that Java Web Start picks up as newer than what was there before the robocopy? – TheCleaner Dec 10 '13 at 20:31
  • Well I believe you understood correctly the problem :) There's one non-obvious use case though: it works perfectly when we load new code, but when we have a bug in the new code and need to fallback, we end up copying an older file which is not picked up by JWS... – foch Dec 11 '13 at 9:28
  • OK, yeah I get you now. I agree with your first comment here. You may consider taking this info I posted and creating a new question over on stackoverflow with your issue. They may have a way to handle this programmatically or possibly a better solution for JWS to handle the rollback properly. – TheCleaner Dec 11 '13 at 13:56
  • So we end up saying it's not possible :( I'll just add a "touch" on all files when we do a fallback. – foch Dec 11 '13 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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