Bob007
Prince Among Men
- Joined
- Dec 22, 2003
- Messages
- 585
Code:
$A = Get-Date
$B = $A.Date
$Date = $B.AddDays(-1)
Get-childitem -path C:\Scripts\ -Recurse -File include *.xml | Where-Object {$_.LasWriteTime -gt $Date} | ForEach-Object {Copy-Item $_.fullName -Destination D:\TestFolderXML\}
Above is an extract from a PS script am working on that will copy xml and wav files created in a single day to a target folder ready for conversion.
The above extract should work independently of everything else. Its ment to get todays date ($A) reset the clock to 00:00:00 ($B) then take a day off (Date). After that it lists all the XML files in a folder and its sub folders (I must point out it works up to here) then for each of them checks it against the date for yesterday and if its lastwritetime is greater (-gt) it copies the files over to the destination.
Except it don't. Am not sure why.
Sugestions ?