• Gosh, that seems like a lot of code to move the newest file from one place to another. Here is how you would do the same in PowerShell:

    $SourceFileSpec = "H:\"

    $DestinationFileSpec = "J:\"

    $NewestFile = Get-ChildItem -Path $SourceFileSpec | Where {-not $_.PSIsContainer} | Sort-Object -Property LastWriteTime -Descending | Select-Object -Property FullName -First 1

    $NewestFile

    Move-Item -Path $NewestFile -Destination $DestinationFileSpec

    #send an email that the file was moved

    You could save this to a .ps1 file and then call it from a SQL Agent CmdExec job step using powershell.exe.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato