0

I'd like to change folder contents without having Date modified change.

I sometimes do cleanup runs on old folders, trying to make space or clean up temp files and dead-ends, or adding relevant links or tags for findability. When I do this, I don't want to change the folder to Date modified: today 2015, because my folders are sorted by Date modified. A project from 2010 should remain timestamped with its last modified date from 2010, because I've only made meta-changes, not actual changes.

Currently I use SK Timestamp or Attribute Changer. I right click each folder before I want to make changes to it, I keep the Properties window open, make my modifications, then hit Apply to overwrite the original timestamps.

I'd like to do it more automated, like set a Cleanup Mode on the root folder D:\Workspace and until I pop that state no timestamps ever get changed in the subdirectories Project2010, Project2013..., Project2015

Either that or at least be able to copy the timestamp between 2 files. Like in this answer that mentions @COPY /B %1+,, %1, but not with current date. Usage like: touch D:\Temp\Project2010\Source.txt Destination.ext

Community
  • 1
  • 1
SouPress
  • 295
  • 1
  • 2
  • 12
  • 1
    you're modifying the contents of a folder, therefore the folder's modified timestamp gets updated as well.: http://stackoverflow.com/questions/1025187/rules-for-date-modified-of-folders-in-windows-explorer – Marc B Jan 19 '15 at 17:54
  • 1
    You could change the system date and time to the date time you wish to keep, then make your changes, then `w32tm /resync` to set the time back to current. – rojo Jan 19 '15 at 20:13

1 Answers1

1

I had commented above with a couple of suggestions -- one involving modifying the system's date / time, and another involving robocopy. The system date / time one is a bit of trouble and requires Internet access, and the robocopy /dcopy:t switch didn't work at all in my tests.

But I found a better solution anyway. Use a for loop to capture the folder's date time to a variable. Then after you've made whatever changes you wish, use powershell to put the folder's date / time back the way it was.

@echo off
setlocal

set "dir=path\to\directory"
for %%I in (%dir%) do set "datetime=%%~tI"

:: Do whatever deletions and other maintenance you want here.

:: Then after all changes have completed, reset the dir timestamp.
powershell -command "(Get-Item '%dir%').LastWriteTime=(Get-Date '%datetime%')"
rojo
  • 24,000
  • 5
  • 55
  • 101