In Windows 7, how can I recursively touch all files in a directory (including subdirectories) in order to update the date/time stamp?
Does Windows 7 have a mechanism to accomplish this?
Answer
There are several possibilities:
Use a port of a Unix
touchcommand and simply combinefindandtouchin the Unix way. There are several choices. Oft-mentioned are GNUWin32, cygwin, and unxutils. Less well known, but in some ways better, are the tools in the SFUA utility toolkit, which run in the Subsystem for UNIX-based Applications that comes right there in the box with Windows 7 Ultimate edition and Windows Server 2008 R2. (For Windows XP, one can download and install Services for UNIX version 3.5.) This toolkit has a large number of command-line TUI tools, frommvanddu, through the Korn and C shells, toperlandawk. It comes in both x86-64 and IA64 flavours as well as x86-32. The programs run in Windows' native proper POSIX environment, rather than with emulator DLLs (such ascygwin1.dll) layering things over Win32. And yes, the toolkit hastouchandfind, as well as some 300 others.
All of these toolkits have the well-known disadvantage of running a separate process for every file to be touched, of course. That's not a problem with the following alternatives.Use one of the many native Win32
touchcommands that people have written and published. Many of them support options to perform recursion, without the necessity for a Unixfindto wrap around them. (They are, after all, targeting a userbase that is looking for atouchcommand because it doesn't have a whole load of ported Unix commands.) One such is Stéphane Duguay'stouchwhich as you can see has a--recursiveoption.Get clever with the arcane mysteries of CMD. As mentioned in the other answer,
COPY /B myfile+,,will update a file's last modification datestamp, using the little-known "plus" syntax of theCOPYcommand (more on which can be found here, incidentally). This of course can be combined withFOR /Rto perform the operation recursively, as hinted at in another answer here.Use a replacement command interpreter and be less clever and more straightforward than CMD. JP Software's TCC/LE is one such. It adds an
/Soption to itsCOPYcommand, meaning that one could useCOPY /Swith the "plus" syntax to eliminate the need for aFORwrapper. But that's really still making life unnecessarily difficult for oneself, considering that TCC/LE has a built in TOUCH command that directly supports an/Soption.
No comments:
Post a Comment