# andyb stackoverflow# http://stackoverflow.com/questions/21979360/powershell-how-to-create-directories-based-on-last-modify-date-of-files # script takes files in folderRoot and moves then to folders at the PATH:YYYYMMDDlevel.file $folderRoot=“B:EXCEL”$days = 1 dir $folderRoot|?{(!($_.PsIsContainer)) -and ((get-date) – $_.lastwritetime).totaldays -gt $days }|%{ [string]$year=$([string]$_.lastwritetime.year) [string]$month=$_.lastwritetime.month [string]$day=$_.lastwritetime.day $dir=$folderRoot+$year+“”+$month+“”+$day if(!(test-path $dir)){ new-item -type container $dir } Write-output $_ move-item $_.fullname $dir}
Related Posts
Python Project with Google Cloud Source Repo
November 7, 2018
My Development Setup – Software & Hardware
July 28, 2018