I try to move my old logfiles to a yyyy\MM\dd folder structure by
Get-ChildItem . -Recurse -Include *.log |
Move-Item -Dest {"D:\Archive\{0:yyyy\\MM\\dd}\{1}" -f $_.LastWriteTime, $_.Name} -Force
but i get a path-not-found error.
update
The source path does not seem to be the problem. It looks like using -Force
on Move-Item
does not create missing destination directories.
sub question: Could the same be done without Get-ChildItem?