Trying to create rotating archive

Advertisement

walkman9999
Joined:
Posts:
2

Trying to create rotating archive

Hello,
I am trying to have a rotating archive of 6 files on a hosted FTP server. Each day a file is created locally (d:\timelapse\timelapse_temp.mp4) and I run a script to rename the files on the server, upload the new file, and then rename it to the current displayed on the website (timelapse.mp4).

Occasionally, one of the files to be renamed doesn't exist and the script errors out. I'm hoping to change the script so that if an error occurs on one of the renames, that the operation continues.

Thanks for any advice.

Script:
*note: edited script to use mv instead of rename, same issue.
open ftp://inbound@[domain].net:[password]@ftp.[domain].net
cd /working/weather
mv timelapse5.mp4 timelapse6.mp4
mv timelapse4.mp4 timelapse5.mp4
mv timelapse3.mp4 timelapse4.mp4
mv timelapse2.mp4timelapse3.mp4
mv timelapse1.mp4 timelapse2.mp4
mv timelapse.mp4 timelapse1.mp4
put d:\timelapse\timelapse_temp.mp4 /working/weather/
mv timelapse_temp.mp4 timelapse.mp4
close
exit
Session log:
. 2024-04-05 09:21:45.081 Connected
. 2024-04-05 09:21:45.081 --------------------------------------------------------------------------
. 2024-04-05 09:21:45.081 Using FTP protocol.
. 2024-04-05 09:21:45.081 Doing startup conversation with host.
> 2024-04-05 09:21:45.081 PWD
< 2024-04-05 09:21:45.109 257 "/" is your current location
. 2024-04-05 09:21:45.109 Getting current directory name.
. 2024-04-05 09:21:45.109 Startup conversation with host finished.
< 2024-04-05 09:21:45.110 Script: Active session: [1] inbound@[domain].net@ftp.[domain].net
> 2024-04-05 09:21:45.110 Script: cd /working/weather
. 2024-04-05 09:21:45.110 Cached directory change via "/working/weather" to "/working/weather".
. 2024-04-05 09:21:45.110 Getting current directory name.
< 2024-04-05 09:21:45.110 Script: /working/weather
> 2024-04-05 09:21:45.111 Script: rename timelapse5.mp4 timelapse6.mp4
. 2024-04-05 09:21:45.111 Listing file "timelapse5.mp4".
. 2024-04-05 09:21:45.111 Retrieving file information...
> 2024-04-05 09:21:45.111 MLST /working/weather/timelapse5.mp4
< 2024-04-05 09:21:45.139 550 Can't check for file existence
. 2024-04-05 09:21:45.139 Could not retrieve file information
< 2024-04-05 09:21:45.139 Script: Can't get attributes of file 'timelapse5.mp4'.
< 2024-04-05 09:21:45.139 Could not retrieve file information
 
< 2024-04-05 09:21:45.139 Can't check for file existence
. 2024-04-05 09:21:45.140 Script: Failed
. 2024-04-05 09:21:45.140 Script: Exit code: 1
. 2024-04-05 09:21:45.143 Disconnected from server

Reply with quote

Advertisement

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

Re: Trying to create rotating archive

Try adding this before the mv commands:
option batch continue
And you might want to reset back afterwards:
option batch abort
https://winscp.net/eng/docs/scriptcommand_option#batch

Another approach is to rename with a mask that matches only the one file you want to rename. For example:
mv [t]imelapse5.mp4 timelapse6.mp4
mv [t]imelapse4.mp4 timelapse5.mp4
mv [t]imelapse3.mp4 timelapse4.mp4
The mv with mask does not fail, if the mask does not match any file.

Reply with quote

Advertisement

You can post new topics in this forum