Transfer all files older than 33 minutes via FTP

Advertisement

OlliPee
Joined:
Posts:
1
Location:
Germany

Transfer all files older than 33 minutes via FTP

I want to check a local directory and transfer all files older than 33 minutes via FTP to another computer. Possibly the transferred files should be moved to a local directory "backup" (optional). However, I have 0 experience how to create such a script. Is there someone who can create such a script for me ? I tried with the code generator but it does not help here.... :-(

I am grateful for any help !
Greetings Olli

Reply with quote

Advertisement

Guest

OK. So far it works already. Thank you for this!!
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\nodered_Daten\log\WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://YYYYYYYYY:xxxxxx@ftp.xxxx.net/ -rawsettings ProxyPort=0" ^
    "lcd C:\nodered_Daten\SM03" ^
    "cd /" ^
    "put -filemask=<33N *" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%
Would there be a possibility to move the sent files to the local computer ? \Backup\* or something like that?
Or another way out, delete the files after sending? (but is less desired!)
The problem is: On the other side runs a program that enters the files into a database and then deletes them. I then move the old plus a few new to the server and he processes them again (which is actually no problem) but the files there then more and more and I can only 200)!

Reply with quote

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

Deleting the uploaded files is easy. Just add -delete to the put command.
https://winscp.net/eng/docs/scriptcommand_put#delete

Moving the uploaded files is more difficult.
Native transactionally-safe support in scripting is tracked here:
Issue 2153 – Moving transferred files to another folder in scripting
You can vote for it in the tracker.

Until that is implemented, see
Moving local files to different location after successful upload

Reply with quote

Advertisement

You can post new topics in this forum