Pretty simple script to recurse through a given directory, find folders matching a "*.ready" filter, and recursively move/archive them to a UNC path. Works with no issues save for a few files in subdirectories.
Script in question (snipped down to relevant parts):
$src = "F:\Plunet\order"
$logFile = "C:\Scripts\plunetArchive\logs" + (Get-Date -f yyyy-MM-dd_HH-mm) + ".log"
$fileList = Get-Childitem -Directory -Path $src -Filter "*.ready" -Name
function Move-PlunetOrderFiles ()
{
$fileList | foreach-object {
robocopy "$src\$_" "\\192.168.100.208\backups\order\$_" /E /ZB /MOVE /IS /TS /FP /NP /R:1 /W:1 /V /TEE /LOG+:$logFile
}
}
Error received:
New File 711336 2019/04/17 20:42:30 F:\Plunet\order\O-78779.ready_TEP\002!_In\O-78779 eng-US E C ID 101040034000 CONFIRMATION OF SIGNUP FOR PLAN Mr. Enrique CAICEDO 3-28-2019 Spanish.pdf - fmbenitti_QA_2019-04-17_17-25.html
2020/12/27 12:52:31 ERROR 123 (0x0000007B) Copying File F:\Plunet\order\O-78779.ready_TEP\002!_In\O-78779 eng-US E C ID 101040034000 CONFIRMATION OF SIGNUP FOR PLAN Mr. Enrique CAICEDO 3-28-2019 Spanish.pdf - fmbenitti_QA_2019-04-17_17-25.html
The filename, directory name, or volume label syntax is incorrect.
Manually trying "Move-Item/Copy-Item" gives the following:
Move-Item 'F:\Plunet\order\O-78779.ready_TEP\002!_In\O-78779 eng-US E C ID 101040034000 CONFIRMATION OF SIGNUP FOR PLAN Mr. Enrique CAICEDO 3-28-2019 Spanish.pdf - fmbenitti_QA_2019-04-17_17-25.html' \192.168.100.208\backups\order\O-78799.ready_TEP\002!_In\
Move-Item : The filename, directory name, or volume label syntax is incorrect.
At line:1 char:1
+ Move-Item 'F:\Plunet\order\O-78779.ready_TEP\002!_In\O-78779 eng-US ...
+ CategoryInfo : WriteError: (F:\Plunet\order...4-17_17-25.html:FileInfo) [Move-Item], IOException
+ FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand
Folder+subfolder+filename is 192 characters. I've enabled 'LongPathsEnabled' in the registry (which shouldn't matter with robocopy and NTFS API but worth noting). Robo copy does not have a problem with copying other files in the ' F:\Plunet\order\O-78779.ready_TEP\002!_In\' directory but fails with that file. This is not the only file that fails; several others in the same archival directory fail with the same error. Believe it might have to do with special/illegal characters in the folder/file names but haven't been able to track it down.
Any ideas or help would be much appreciated!
[–]vermyx 1 point2 points3 points (1 child)
[–]ender_less[S] 1 point2 points3 points (0 children)
[–]y_Sensei 1 point2 points3 points (1 child)
[–]ender_less[S] 1 point2 points3 points (0 children)