I need to update the modified date (and accessed date) of all files in a directory (Windows 10) and its subdirectories so that my company doesn't automatically delete them after a year of no modifications.
There might be thousands of files inside the directory so obviously, I can't do it manually.
It would be great if it could be done without using Python or other programming languages that need to be installed due to limited permissions in the system, directly with Windows CMD commands, but if it is necessary I might be able to get some temporary permissions.
As suggested in the comments, I've tried to use:
cd c:\yourFolder
copy c:\yourFolder,,
But the solution doesn't update the files inside the subdirectories of my folder, so is there a way to do it for all the subdirectories in the tree?
CodePudding user response:
Open the command prompt and navigate to your folder and execute the copy command with ,, params , example as follow.
cd c:\yourFolder
copy c:\yourFolder,,
CodePudding user response:
I have solved it by using the Windows PowerShell. After copying the complete directory, in PowerShell I did:
cd "C:\mydirectory"
dir -R | foreach { $_.LastWriteTime = [System.DateTime]::Now }
Which recursively "touched" all the files in the directory and subdirectories to make it look as if they had all been recently modified