Martin,
You're a life-saver!
Regards,
VtR
You're a life-saver!
Regards,
VtR
$fileName = Split-Path -Path $transfer.FileName -Leaf -Resolve
Move-Item "$folders.localPath\$fileName" $folders.finalPath
"+ CategoryInfo : ObjectNotFound: (C:\dtl_ftp\bin...ntArgs.FileName:String) [Split-Path], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SplitPathCommand"
# Iterate over every transfer
foreach ($transfer in $transferResult.Transfers)
{
# Success or error?
if ($transfer.Error -eq $Null)
{
Write-Host "Upload of $($transfer.FileName) succeeded, moving to backup"
# Download succeded, move source file to backup and download from temp to final
$session.MoveFile($transfer.FileName, $folders.backupPath)
Move-Item $transfer.FileName $folders.finalPath
}
else
{
Write-Host "Upload of $($transfer.FileName) failed: $($transfer.Error.Message)"
}
}
Is this the proper addition to move the freshly downloaded file to a different directory on the same server?
Move-Item
.
# Iterate over every transfer
foreach ($transfer in $transferResult.Transfers)
{
# Success or error?
if ($transfer.Error -eq $Null)
{
Write-Host "Upload of $($transfer.FileName) succeeded, moving to backup"
# Download succeded, move source file to backup
$session.MoveFile($transfer.FileName, $backupPath)
}
else
{
Write-Host "Upload of $($transfer.FileName) failed: $($transfer.Error.Message)"
}
}
# Iterate over every transfer
foreach ($transfer in $transferResult.Transfers)
{
# Success or error?
if ($transfer.Error -eq $Null)
{
Write-Host "Upload of $($transfer.FileName) succeeded, moving to backup"
# Download succeded, move source file to backup and download from temp to final
$session.MoveFile($transfer.FileName, $backupPath)
Move-Item $transfer.FileName $finalPath
}
else
{
Write-Host "Upload of $($transfer.FileName) failed: $($transfer.Error.Message)"
}
}
$foldersList = Import-Csv -Header ("Source", "Dest", "Archive") "paths.csv"
foreach ($folders in $foldersList)
{
# ...
}
$session.PutFiles
call and foreach ($transfer in $transferResult.Transfers)
loop from the example code. Replace $localPath
, $remotePath
and $backupPath
with $folders.Source
, $folders.Dest
and $folders.Archive
.
/user/fromFolder1, c:/ftp/downloads/toFolder1, /user/archive/archiveFolder1
/user/fromFolder2, c:/ftp/downloads/toFolder2, /user/archive/archiveFolder2
/user/fromFolder3, c:/ftp/downloads/toFolder3, /user/archive/archiveFolder3
/user/fromFolder4, c:/ftp/downloads/toFolder4, /user/archive/archiveFolder4
/user/fromFolder5, c:/ftp/downloads/toFolder5, /user/archive/archiveFolder5
/user/fromFolder6, c:/ftp/downloads/toFolder6, /user/archive/archiveFolder6
/user/fromFolder7, c:/ftp/downloads/toFolder7, /user/archive/archiveFolder7
/user/fromFolder8, c:/ftp/downloads/toFolder8, /user/archive/archiveFolder8