Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

powershell or other script to make files creation date = modified date

something messed up my mp3 and image library. Now, the files have correct modified data but the creation date is newer!

That for some reason makes using robocopy to backup my library impossible (robocopy thinks files are always changing, even when they did not).

I saw some tools people wrote to let you edit via gui or even cmd line the properties of files, but all expect you to tell them the date you want to set. that will not work since I have files in different dates cross 10 years.

i figured it is a simple powershall script to iterate over folder/sub folder and set each files creation date to be the modified date.

Any poweshall wizard that can show me the way? or at least get me started?

like image 225
csmba Avatar asked Dec 03 '25 09:12

csmba


1 Answers

Get-ChildItem -recurse -filter *.mp3 | % { $_.CreationTime = $_.LastWriteTime }

That should do the job.

like image 96
ravikanth Avatar answered Dec 06 '25 02:12

ravikanth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!