Hello there,
i have made a script according to the docu. I have a local ftps, there are different folders (with files in it) in the /root/ directory, it contains several database backups, that gets generated every 4 minutes and i want to download the newest files only and not the older stuff so i made this script but it doesnt work so far. It would be nice, if someone could check it:
i have made a script according to the docu. I have a local ftps, there are different folders (with files in it) in the /root/ directory, it contains several database backups, that gets generated every 4 minutes and i want to download the newest files only and not the older stuff so i made this script but it doesnt work so far. It would be nice, if someone could check it:
FTP Script
- :connect
- #connect to the ftp
- #check if connection is possible, if not reconnect
- GOTO :connect
- #Set local download dir
- #Set remote dire
- #Loop for fetching files
- #Get remote file list
- #Get the current date
- #Check all files in remote dir and download them
Hi Mike,
To download the most recent files the SYNC command is what you probably need.
https://www.scriptftp.com/d/ftp-transfer-commands/sync
Also, you can use date comparing to determine if a remote file should be downloaded or not. This is not related to the SYNC command, it is another way to accomplish what you want.
Here is an example that does some date operations. It is not exactly what you need but if you read the comments you will understand how to compare a date of a file against any date you define etc.
https://www.scriptftp.com/s/average-scripts/older_than_a_week-ftp
If you need further help feel free to post here again.
To download the most recent files the SYNC command is what you probably need.
https://www.scriptftp.com/d/ftp-transfer-commands/sync
Also, you can use date comparing to determine if a remote file should be downloaded or not. This is not related to the SYNC command, it is another way to accomplish what you want.
Here is an example that does some date operations. It is not exactly what you need but if you read the comments you will understand how to compare a date of a file against any date you define etc.
https://www.scriptftp.com/s/average-scripts/older_than_a_week-ftp
If you need further help feel free to post here again.
liked Script FTP? Try our other product Email Parser
Ive watched the documentation again and made another script. This is not the "end version" of my script, the timedifferenz parameter is missing too, didnt added it.
I know the SYNC "Tag" but the problem is, I don't want to remove the folders with the files inside from my ftp and the downloaded files from the ftp are move to another dir via another script. So in this scenario, SYNC would download the files again, so i need a bypass somehow
FTP Script
- :connect
- #connect to the ftp
- #check if connection is possible, if not reconnect
- GOTO :connect
I know the SYNC "Tag" but the problem is, I don't want to remove the folders with the files inside from my ftp and the downloaded files from the ftp are move to another dir via another script. So in this scenario, SYNC would download the files again, so i need a bypass somehow
Here is a new update:
I've managed to get it to work, but it is pretty time consuming (I have around 4000 folders inside the ftp and the scanning process (GetList) is time consuming as f*ck). The FTP server has a time difference of 3hours so i added it with 3h and added another 5 minutes to the Systemtime to collect files that are up to 5 minutes available. I would like to use SYNC but the filter options are pretty "bad", there are a few but time filtering without scanning every folder for the date is a pretty bad bypass for me. Is there another way maybe ?
Creating a Directory isn't working with parameters, in the second FOREACH before the download, but idk why..
I tried almost every FTPs client, but there isn't one, that fits to my needs but ScriptFTP is near.
I've managed to get it to work, but it is pretty time consuming (I have around 4000 folders inside the ftp and the scanning process (GetList) is time consuming as f*ck). The FTP server has a time difference of 3hours so i added it with 3h and added another 5 minutes to the Systemtime to collect files that are up to 5 minutes available. I would like to use SYNC but the filter options are pretty "bad", there are a few but time filtering without scanning every folder for the date is a pretty bad bypass for me. Is there another way maybe ?
Creating a Directory isn't working with parameters, in the second FOREACH before the download, but idk why..
I tried almost every FTPs client, but there isn't one, that fits to my needs but ScriptFTP is near.
FTP Script
- :connect
- #connect to the ftp
- #check if connection is possible, if not reconnect
- GOTO :connect
- $ZeitSystem5=$ZeitSystem-(300)
- $ZeitDateien5=$ZeitDateien+(3*60*60)
Creating a Directory isn't working with parameters, in the second FOREACH before the download, but idk why
I don't see where you are trying to create a directory in the script. Just note, if it helps, that creating a directory in ScriptFTP does not accept any extra parameters, just the directory name.
Is there another way maybe ?
Unfortunately no, there is no other way, sorry. May be, if you have so many folders running separate FTP scripts in parallel may help. One script will process the folders starting with the A letter, then another one with the B and so on:
FTP Script
If you don't want to write a script for every letter you can pass the letter as a parameter in the command line and then retrieve it within the script with GETPARAM
liked Script FTP? Try our other product Email Parser
Thank you, i will try it out
- All times are UTC -