5

How to exclude files or folder not to be transferred to server with Windows PuTTY PSCP command?

My command:

pscp -r -i "D:\my-key.ppk" D:\wamp\www\abc\* ec2-user@58.55.86.157:/var/www/html

It transfers all files and directories. I want to exclude some directory let's say runtime\ and its content.

I googled but no commands found.

Please help.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Shahid Karimi
  • 4,096
  • 17
  • 62
  • 104

1 Answers1

5

The pscp does not have any filters. All you can do is to explicitly list all the other files and folders for upload, skipping the runtime.

pscp -r -i "D:\my-key.ppk" D:\wamp\www\abc\file1 D:\wamp\www\abc\file2 ... ec2-user@58.55.86.157:/var/www/html

Or use another SFTP/SCP client, which supports filters (exclude masks).

For example, with WinSCP scripting you can use this batch file (.bat):

winscp.com /command ^
    "open sftp://ec2-user@58.55.86.157/ -hostkey=""ssh-rsa ..."" -privatekey=""D:\my-key.ppk""" ^
    "put D:\wamp\www\abc\* /var/www/html/ -filemask=""| runtime\""" ^
    "exit"

References:

(I'm the author of WinSCP)

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992