Well i give you something to work with:
get-childitem | select LastWriteTime
finally if you want to check each file for a specific date use:
get-childitem | foreach-object {
if ($_.lastwritetime.year -eq 2013) {
write-host $_.Name was created 2013
} else {
write-host $_ was not created 2013
}
}
In Batch you would do it like this:
for /d %%f in (*) do @echo %%f is born on %%~tf
so you could in theory have something like:
@echo off
setlocal ENABLEDELAYEDEXPANSION
for %%f in (*) do (
set FILE_DATE="%%~tf"
set FILE_YEAR=!FILE_DATE:~7,4!
if !FILE_YEAR! == 2013 (
echo %%f was born in 2013
) else (
echo %%f was not born in 2013
)
)
But be carefull, first see what %%~tf will output on your machine, since the format of DateTime output often varies in different cultures. Essentially you have to work on the substring in !FILE_DATE!
Final Edit:
So this is as far as I go doing your job :)
new-variable now -value (date)
new-variable nact -value ((date).addyears(20))
get-childitem *.bkf | foreach-object {
set-variable nact -value (($_.lastaccesstime).addyears(20))
if ($_.lastaccesstime.year -le $now.year) {
write-host [$now]: Updateing LastAccessTime of $_.name to $nact
$_.lastaccesstime = ($nact)
} else {
write-host [$now]: Ignoring $_.name
}
}
This will look at every *.bkf file in the current folder, and if it's last access time by year is lesser or equal to the current year, it will add 20 years to it's last access time. Every other file is left alone.