Schedule upload of select files based on time period

Advertisement

comfortablynumb
Joined:
Posts:
2

Schedule upload of select files based on time period

Howdy,
I'm trying to work out a script I can run as a scheduled task that will upload any files that have changed or are new in a directory and this task will run every 4 to 8 hours, not sure yet. I can't get the time mask to work.

I've gotten this far with a script, but when I put the time flag in it fails.

I've tried running this by using a command line winscp.exe /script="c:\temp\test.txt" /parameter xmllog=c:\temp\log.txt

The log isn't helping me as there's not much in the log for info.

I want to upload files every 4 hours. The source directory is on a Windows server - not sure if the slash should be \ but I think so as it works fine until I put the time in as >8H

Then the destination I put as /TEST/Log-Folder

I want all files in the folder under temp to upload. I have tried putting the path as D:\Temp\*\*.*>8H and then D:\Temp\Logs\*.*>8H

#Automatically answer all prompts negatively not to stall the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# creds saved in winscp - username & pwd are saved
open Testsite
cd
# Force binary mode transfer
option transfer binary
# Put logs in remote directory from the last 8 hours
put D:/Temp/Logs/*.*>8H /TEST/Logs-Folder
close
# Exit WinSCP
Exit

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Schedule upload of select files based on time period

comfortablynumb wrote:

I've tried running this by using a command line winscp.exe /script="c:\temp\test.txt" /parameter xmllog=c:\temp\log.txt

The log isn't helping me as there's not much in the log for info.
The syntax should be: winscp.exe /script=c:\temp\test.txt /xmllog=c:\temp\log.txt
Also you probably want to use /log instead of /xmllog, if you want the log for debugging purposes.

put D:/Temp/Logs/*.*>8H /TEST/Logs-Folder
Should be: put -filemask=>8H D:\Temp\Logs\*.* /TEST/Logs-Folder/

Anyway, whey don't use synchronize?
https://winscp.net/eng/docs/scriptcommand_synchronize

Reply with quote

ScriptHelpPlease
Guest

Re: Schedule upload of select files based on time period

martin wrote:

comfortablynumb wrote:

I've tried running this by using a command line winscp.exe /script="c:\temp\test.txt" /parameter xmllog=c:\temp\log.txt

The log isn't helping me as there's not much in the log for info.
The syntax should be: winscp.exe /script=c:\temp\test.txt /xmllog=c:\temp\log.txt
Also you probably want to use /log instead of /xmllog, if you want the log for debugging purposes.

put D:/Temp/Logs/*.*>8H /TEST/Logs-Folder
Should be: put -filemask=>8H D:\Temp\Logs\*.* /TEST/Logs-Folder/

Anyway, whey don't use synchronize?
https://winscp.net/eng/docs/scriptcommand_synchronize

I didn't want to use the synchronize because I'm uploading to an ftp site I don't control. However I can use just a task that uploads the logs that have been modified or created for that "day", I don't need to be time specific.
I have to run this as a scheduled task in Windows and then email the result code of the scheduled task as well as the log on whether the upload worked, can anyone help?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Schedule upload of select files based on time period

ScriptHelpPlease wrote:

I didn't want to use the synchronize because I'm uploading to an ftp site I don't control. However I can use just a task that uploads the logs that have been modified or created for that "day", I don't need to be time specific.
How is uploading files modified/creates in a certain day not a time specific?

Anyway, continuing here:
https://winscp.net/forum/viewtopic.php?t=12887

Using relative time is definitely easier.

Reply with quote

Advertisement

You can post new topics in this forum