Temp file - Last file not MOVED

Welcome Forums General PowerShell Q&A Temp file - Last file not MOVED

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 3 months ago.

  • Author
  • #62815

    Topics: 3
    Replies: 1
    Points: 0
    Rank: Member


    I have the following code and it copies all the files from "temp" to "incomingfiles" folder – Though the last file doesn't move to the incomingfiles folder and remains in the temp folder. Why does this happen?

    Any help please with the code or what is causing this;

    #Sub folder used to hold newly fetched encrypted zips
    $temporarySubfolder = "Temp\"
    #Sub folder used to hold decrypted uncompressed files
    $unzipSubdirFolder = "ZipTemp\"
    #Output folder for fetched, decrypted, re-compressed files
    $destinationSubfolder = "IncomingFiles\"

    # Destination directories
    $temporaryTransferFolder = Join-Path $rootFolder $temporarySubfolder
    $destinationFolder = Join-Path $rootFolder $destinationSubfolder

    # Set transfer options to simple binary transfer, overwriting existing file
    # This is because we are handling abort resume ourselves
    $transferOptions = New-Object WinSCP.TransferOptions -Property @{
    TransferMode = [WinSCP.TransferMode]::Binary
    ResumeSupport = New-Object WinSCP.TransferResumeSupport -Property @{
    State = [WinSCP.TransferResumeSupportState]::Off
    OverwriteMode = [WinSCP.OverwriteMode]::Overwrite

    foreach ($remoteFile in $collectionFiles) {
    Write-Host "Retrieving " $remoteFile.Name

    #Determine path to remot file
    $remoteFilePath = $remotePath + "/" + $remoteFile.Name
    $localTempFilePath = Join-Path $temporaryTransferFolder $remoteFile.Name

    #Fetch the file
    $session.GetFiles($session.EscapeFileMask($remoteFilePath), $localTempFilePath).Check()

    #Verify transfer with checksum
    $remoteChecksum = [System.BitConverter]::ToString($session.CalculateFileChecksum("sha-1", $remoteFilePath))
    $sha1 = [System.Security.Cryptography.SHA1]::Create()
    $localChecksum = "NotYetSetNotNull"
    try {
    $localStream = [System.IO.File]::OpenRead($localTempFilePath)
    $localChecksum = [System.BitConverter]::ToString($sha1.ComputeHash($localStream))


  • #62845

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Would you mind posting your code with the code formatting, as indicated in the bullet list above the posting text box? It's unfortunately very difficult to follow without formatting.

The topic ‘Temp file - Last file not MOVED’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort