Command line or Batch file Script for new files in last day

Advertisement

randydover
Joined:
Posts:
1
Location:
TN

Command line or Batch file Script for new files in last day

I have configured the console to connect to a site and it will transfer files.
I need to automate this so it can be done via a scheduled task in Windows.
The command I am using successfully connects to the remote server, and attempts to download, but the log shows "Missing parameter for command 'get'."

What I am attempting to do is get files changed / created in the last day and download them to a folder on C:

The commands I'm using are:
open sftp://remotesite -hostkey="ssh..."
get -filemask="/Users/RFTP772/*>=1D"

I have also tried:
open sftp://remotesite -hostkey="ssh..."
get -filemask=/Users/RFTP772/"*>=1D", "C:\upload\extracts"

and:
open sftp://remotesite -hostkey="ssh..."
get -filemask=/Users/RFTP772/"*>=1D C:\upload\extracts"

Every time I issue any of those commands I get in the log file:
"Missing parameter for command 'get'."

I have looked a lot in the forums, but do not know how to get past this. I am very familiar with scripting, but not with WinSCP. As I am not familiar with WinSCP script, could someone give me the exact command to get all files changed in the last day and put them in C:\upload\extract

I have tried saving the options from the console session, but it doesn't have the get commands, so I don't know how to pull down the files and put them in the folder I need them to go into. The console "generate" does not have the commands to get and save the files, though that is in the console. Is there a way to get the "generate" to show the commands needed?

I did notice there are significant differences between the "script" and "batch" commands when I generate the script. I am creating a batch file to pull the files, and will use a scheduled task to call that batch file.

Thanks to all.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Command line or Batch file Script for new files in last day

You want this:

get /Users/RFTP772/*>=1D

If you need to download even files in subfolders, then you need the -filemask:

get /Users/RFTP772/* -filemask=*>=1D

Reply with quote

Guest

Re: Command line or Batch file Script for new files in last day

Martin,
Thanks! That did it.
I did find I had to put the "\" at the end of extracts, that was the only thing I had to change, other than your change.

Reply with quote

Advertisement

You can post new topics in this forum