NEED a PowerShell Script to find file and folders with specific created: date and change the same.

rated by 0 users
This post has 2 Replies | 2 Followers

Not Ranked
Posts 2
YogeshNeedsScript Posted: 04-17-2012 9:30 AM

Hi

I am looking for a script to find files and folders with specific created: date and then change the created: date.

 

I have some folders and files which show a specific created: date . The date is wrong.

I  found the command to change the created: date but then I have to search files and folders in the entire drive.

The command to change created: date on folder

$(get-item hot).creationtime=$(get-date "08/31/1980")

The command to change created: date for all files and folders in a folder.

$Now= "Saturday, April 21, 2012 3:12:13 AM"

$Now1="Saturday, April 21, 2012 3:12:13 AM"

$TargetFolder = Get-ChildItem "C:\hot"

foreach($file in $Targetfolder)

{

$file.creationtime = $Now

$file.lastwritetime = $Now1

}

$TargetFolder

 

But I need a script that can search files and folders having a specific created: date and then automaitcalyl change the same to a specific date.

 

Regards

Yogesh

Top 10 Contributor
Posts 640

There's no fast way to do this, unfortunately. 

Get-ChildItem <path> -recurse | Where { $_.creationtime -eq 'your date here' } | ForEach { $_.creationtime = 'your new date' }

Is essentially it - I'm not able to test and write the exact code, but the idea is to use a Where-Object to see if each one equals your desired date. This is going to take a long time to run if you have a lot of files, but there's really no other way to do it.

Not Ranked
Posts 2
Page 1 of 1 (3 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.