rem # Katherine Villyard, 10/7/13 rem # Copy files from smallest to largest via SFTP. set instance=%~1 if %instance%z==z goto :_help set flag="f:\full backups\%instance%\flag.txt" :loop IF EXIST %flag% ( GOTO file_found ) else ( ping 127.0.0.1 GOTO loop ) :file_found dir "f:\full backups\%instance%" /os /b /a-d-h > c:\temp\%instance%.txt echo lcd "f:\full backups\%instance%" >> c:\temp\%instance%-control.txt echo cd %computername%-%instance% >> c:\temp\%instance%-control.txt FOR /F %%L IN (c:\temp\%instance%.txt) DO ( echo put %%L >> c:\temp\%instance%-control.txt ) echo quit >> c:\temp\%instance%-control.txt "c:\Program Files (x86)\PuTTY\psftp.exe" Atlanta -b c:\temp\%instance%-control.txt del c:\temp\%instance%-control.txt del c:\temp\%instance%.txt goto :_end :_help @echo. @echo Please specify an instance. :_end exit