Can we delete file using PSCP?

Hello,

I am using PSCP to do file transfer from remote server to window system. It works well.

But the file is only copying, but in my case once after file copied, we should not have the same file on the remote server it should be moved to the windows system or deleted on the remote server after copied.

So please give me a suggestion how to delete that file on remote server using PSCP.

--
Thanks,
Mohan

PSCP does not support deleting a file. psftp does. See the pscp download page to download psftp.

Thanks, I will use PSFTP instead of PSCP.

I have few questions if i use PSFTP

I am using the below syntax to connect to server,
psftp.exe -l testlogin -pw testpassword -b script.bat host.name.net
all my file movement code in script.bat

script.bat contains:
cd SERVER/GETFILE
lcd C:\INBOUND
get Test one.txt
quit

  1. How to get latest file from the server, example i am using test one.txt
  2. How to get return codes from the script.bat
  3. How to rename file name "Test one.txt" to "YYYYMMDDHHDDSS.txt" when GET
  4. How to rename file name "YYYYMMDDHHMMSS.txt" to "Test one.txt" when PUT

Can you please clear my questions i can do all these using PSCP but, when i use code in the script.bat it doesn't recognizes keywords like "@ echo off" "IF" "SET etc.

If i have a way to delete file using PSCP, or any idea to delete that file from server from the same script program i dont have to change all the code again.

--
Thanks
Mohan

The renaming of the files should be done by the batch file before / after the call to the psftp program. It does the transfer, it doesn't have to do everything else, that is why you have a batch file. The script.bat file is instructions for psftp. The place for the other instructions should be in the .bat file that calls psftp. To make things clearer, rename script.bat to script.spftp. This is not a .bat file so should not be labeled as a .bat file!

Use PSCP.EXE to get the file and PSFTP.EXE to delete after checking the return code.

PSCSP.EXE [options]
IF �%ERRORLEVEL%� == �1� GOTO ERROR
PSFTP.EXE [options] -b del.batch
GOTO END
:ERROR
ECHO "There was an error getting the file."
REM Use blat.exe to send emails. SourceForge.net: Blat - A Win32 Command Line SMTP Mailer
:END