I want to move files to a sub folder when I am done with them.
The below code moves a test file called test.dav
to /archive
just fine.
The files I get are however weirdly named, and I can't change that. They are generated by a system I do not control.
Examples of those file names being:
- 23.51.54-23.52.19[M][0@0][0].dav
- 23.52.32-23.52.55[M][0@0][0].dav
I am using the following script to do some processing on them and then to move.
Get-ChildItem "C:\NVR\CameraDrop\dump" -Filter *.dav | ForEach-Object {
#Doing processing here#
try {
Move-Item -Path "$($_.FullName)" -Destination "C:\NVR\CameraDrop\dump\archive\$($_.Name)" -force
"Successfully moved" }
catch {
"Error moving $_.FullName"
}
}
The problem is the above code and specifically Move-Item
fails to move real files but does work on normally named files. It still reports success though ;)
Powershell is not my forte, but I thought it might be because I need to escape the paths since they have all those nasty characters in them but that did not help either.
Help please :)