I am trying to move old log files to the yyyy \ MM \ dd folder structure on
Get-ChildItem . -Recurse -Include *.log |
Move-Item -Dest {"D:\Archive\{0:yyyy\\MM\\dd}\{1}" -f $_.LastWriteTime, $_.Name} -Force
but I get an error not found in the path.
Update
The source path does not seem to be a problem. It seems that using -Forceon Move-Itemdoes not create missing destination directories.
additional question : Is it possible to do this without Get-ChildItem?
source
share