File management
-
Wednesday, May 09, 2012 9:03 PMHi,i would like to write a powershell script, that make the following:- search in a rootdirectory for all files- if in rootdirectory exists the file with last write time yyyy.MM.01, write to host and search for yyyy.MM.17- if a file not exists with last write time yyyy.MM.01, search for yyyy.MM.02, if 02 not exists search for 03.....- if a file not exists with last write time yyyy.MM.17, search for 18....I have written a script for this, but doesn't work:foreach($year in $years){foreach($month in $months){$day1=1$day2=31while($day1 -lt $day2){Get-ChildItem -Path $routepath | Where-Object { $_.Mode -notmatch 'd' } | ForEach-Object {if($year -eq $_.lastwritetime.year -and $month -eq $_.lastwritetime.month -and $day1 -eq $_.lastwritetime.day){$_$day1 = 17}else{$day1 += 1}}}}}can you help me?Thanks,gonan86
All Replies
-
Wednesday, May 09, 2012 9:18 PM
Your description of how the program should work doesn't make sense. That is not proper psuedo-code. There are too many questions unanswered.
Please think carefully about what you want, and be sure to cover all scenarios.
Once you have the idea fully thought out, you may be able to write some sensible code. The code you posted makes no sense either.
Grant Ward, a.k.a. Bigteddy
- Marked As Answer by Yan Li_Microsoft Contingent Staff, Moderator Thursday, May 17, 2012 1:29 AM
- Unmarked As Answer by Yan Li_Microsoft Contingent Staff, Moderator Thursday, May 17, 2012 1:29 AM
-
Friday, May 11, 2012 6:37 AMModerator

