Only download if other file does not exist
8 posts
• Page 1 of 1
Only download if other file does not exist
I use ScriptFTP to download files with the extension *.PS
When downloaded, they are renamed to *.MPG (can this be easy done inside the script, now I do it after the FTP with a batch file in the task-scheduler)
The FTP session is also started with the task-scheduler, every 15 minutes, so if there 's a new file in the FTP side, it will be downloaded, but, since i rename the files to *.MPG the file is downloaded again and again.
So is there a way i can check it ?
if FILE1.MPG exists local , do NOT download FILE1.PS
if FILE1.MPG does NOT exist local, download file1.PS and rename it after download to FILE1.MPG
this has to be done for all the files on the remote FTP.
I was thinking of using the script :
But I don't know if i can exlude the name with ALL the extensions ?
someting like :
When downloaded, they are renamed to *.MPG (can this be easy done inside the script, now I do it after the FTP with a batch file in the task-scheduler)
The FTP session is also started with the task-scheduler, every 15 minutes, so if there 's a new file in the FTP side, it will be downloaded, but, since i rename the files to *.MPG the file is downloaded again and again.
So is there a way i can check it ?
if FILE1.MPG exists local , do NOT download FILE1.PS
if FILE1.MPG does NOT exist local, download file1.PS and rename it after download to FILE1.MPG
this has to be done for all the files on the remote FTP.
I was thinking of using the script :
GETLIST($list, LOCAL_FILES, "*.*")
CLEAREXCLUSION()
FOREACH $item IN $list
ADDEXCLUSION(DOWNLOAD, $item)
END FOREACH
CLEAREXCLUSION()
FOREACH $item IN $list
ADDEXCLUSION(DOWNLOAD, $item)
END FOREACH
But I don't know if i can exlude the name with ALL the extensions ?
someting like :
- Code: Select all
ADDEXCLUSION(DOWNLOAD, $item.*)
- efiten
- Posts: 7
- Joined: 21 Nov 2011, 08:57
Re: Only download if other file does not exist
Download the specified file and save it using a different name.efiten wrote:I use ScriptFTP to download files with the extension *.PS
When downloaded, they are renamed to *.MPG (can this be easy done inside the script, now I do it after the FTP with a batch file in the task-scheduler)
- WAndrey
- Posts: 76
- Joined: 24 Dec 2009, 14:28
Re: Only download if other file does not exist
how to retrieve the suffix from the name of a fileefiten wrote:But I don't know if i can exlude the name with ALL the extensions ?
someting like :
- Code: Select all
ADDEXCLUSION(DOWNLOAD, $item.*)
- WAndrey
- Posts: 76
- Joined: 24 Dec 2009, 14:28
Re: Only download if other file does not exist
Maybe so? Efficiency is not checked. Sorry for my English, I used translate.google.com
GETLIST($aLocalList, LOCAL_FILES, "*.MPG")
GETLIST($aRemoteList, REMOTE_FILES, "*.PS")
$aLocalName = ""
$aRemoteName = ""
FOREACH $aFileName IN $aLocalList
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aLocalName = $aLocalName.$aName."|"
END FOREACH
FOREACH $aFileName IN $aRemotelist
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aRemoteName = $aRemoteName.$aName."|"
END FOREACH
FOREACH $aRemote IN $aRemoteName
$aFound = 0
FOREACH $aLocal IN $aLocalName
IF($aRemote == $aLocal)
$aFound = 1
END IF
END FOREACH
IF($aFound == 0)
GETFILE2($aRemote.".PS", $aRemote.".MPG")
END IF
END FOREACH
GETLIST($aRemoteList, REMOTE_FILES, "*.PS")
$aLocalName = ""
$aRemoteName = ""
FOREACH $aFileName IN $aLocalList
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aLocalName = $aLocalName.$aName."|"
END FOREACH
FOREACH $aFileName IN $aRemotelist
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aRemoteName = $aRemoteName.$aName."|"
END FOREACH
FOREACH $aRemote IN $aRemoteName
$aFound = 0
FOREACH $aLocal IN $aLocalName
IF($aRemote == $aLocal)
$aFound = 1
END IF
END FOREACH
IF($aFound == 0)
GETFILE2($aRemote.".PS", $aRemote.".MPG")
END IF
END FOREACH
- WAndrey
- Posts: 76
- Joined: 24 Dec 2009, 14:28
Re: Only download if other file does not exist
I'm testing it at the moment, it looks good, the only thing I had to change was putting the extension in lower case, as the FTP is linux based.
Many thanks for this great help.
I'll let you know when the testing is finished, and if I had to make some changes.
Many thanks for this great help.
I'll let you know when the testing is finished, and if I had to make some changes.
- efiten
- Posts: 7
- Joined: 21 Nov 2011, 08:57
Re: Only download if other file does not exist
It's not completely OK.
It is strange, but it seems to miss the first LOCAL file in the list.
the REMOTE list is OK
I added a print commando; to view the filenames :
And after a few files it goes wrong, the local and remote files do not match, and they do exist.
It is strange, but it seems to miss the first LOCAL file in the list.
the REMOTE list is OK
I added a print commando; to view the filenames :
$aLocalName = ""
$aRemoteName = ""
GETLIST($aLocalList, LOCAL_FILES, "*.mpg")
FOREACH $aFileName IN $aLocalList
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aLocalName = $aLocalName.$aName."|"
END FOREACH
FOREACH $aLocal IN $aLocalName
PRINT("Local : ".$aLocal)
END FOREACH
GETLIST($aRemoteList, REMOTE_FILES, "*.ps")
FOREACH $aFileName IN $aRemotelist
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aRemoteName = $aRemoteName.$aName."|"
END FOREACH
FOREACH $aRemote IN $aRemoteName
PRINT("Remote : ".$aRemote)
END FOREACH
FOREACH $aRemote IN $aRemoteName
$aFound = 0
FOREACH $aLocal IN $aLocalName
IF($aRemote == $aLocal)
$aFound = 1
END IF
END FOREACH
IF($aFound == 0)
GETFILE2($aRemote.".ps", $aRemote.".mpg")
END IF
END FOREACH
$aRemoteName = ""
GETLIST($aLocalList, LOCAL_FILES, "*.mpg")
FOREACH $aFileName IN $aLocalList
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aLocalName = $aLocalName.$aName."|"
END FOREACH
FOREACH $aLocal IN $aLocalName
PRINT("Local : ".$aLocal)
END FOREACH
GETLIST($aRemoteList, REMOTE_FILES, "*.ps")
FOREACH $aFileName IN $aRemotelist
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aRemoteName = $aRemoteName.$aName."|"
END FOREACH
FOREACH $aRemote IN $aRemoteName
PRINT("Remote : ".$aRemote)
END FOREACH
FOREACH $aRemote IN $aRemoteName
$aFound = 0
FOREACH $aLocal IN $aLocalName
IF($aRemote == $aLocal)
$aFound = 1
END IF
END FOREACH
IF($aFound == 0)
GETFILE2($aRemote.".ps", $aRemote.".mpg")
END IF
END FOREACH
And after a few files it goes wrong, the local and remote files do not match, and they do exist.
GETLIST(LOCAL_FILES,"*.mpg")
Getting file listing of current local directory
Found 9 files.
Local : JPL_PGM_W26_MON-GNK_N
Local : JPL_PGM_W26_OHL-CER_N
Local : JPL_PGM_W26_STV-LIE_N
Local : JPL_PGM_W27_BEE-OHL_N
Local : JPL_PGM_W27_CER-ZWA_N
Local : JPL_PGM_W27_GNT-MON_N
Local : JPL_PGM_W27_KOR-LOK_N
Local : JPL_PGM_W27_WES-MEC_N
Local :
GETLIST(REMOTE_FILES,"*.ps")
Getting file listing of current remote directory
Found 10 files.
Remote : JPL_PGM_W26_MEC-BEE_N
Remote : JPL_PGM_W26_MON-GNK_N
Remote : JPL_PGM_W26_OHL-CER_N
Remote : JPL_PGM_W26_STV-LIE_N
Remote : JPL_PGM_W27_BEE-OHL_N
Remote : JPL_PGM_W27_CER-ZWA_N
Remote : JPL_PGM_W27_GNT-MON_N
Remote : JPL_PGM_W27_KOR-LOK_N
Remote : JPL_PGM_W27_WES-MEC_N
Remote :
GETFILE2("JPL_PGM_W26_MEC-BEE_N.ps","JPL_PGM_W26_MEC-BEE_N.mpg")
Downloading................. JPL_PGM_W26_MEC-BEE_N.ps as JPL_PGM_W26_MEC-BEE_N.mpg
- efiten
- Posts: 7
- Joined: 21 Nov 2011, 08:57
Re: Only download if other file does not exist
I am guided by the section GETLIST where it is stated:
I gotThe changes were lines forming the list, the symbol "|" to add an element, but not after.
Sorry for my English, I used translate.google.com
A checking this code:Every ScriptFTP variable contains a text string and the list that this command creates is not an exception. The character "|" is used to separate the items of the list. Therefore, you can also build file lists without GETLIST. For example: $mylist="a.txt|b.txt|c.txt".
I got
Thus we see an inaccuracy in the documentation and the code should look like this:|1.ftp|AUTOEXEC.BAT|boot.ini|Bootfont.bin|CONFIG.SYS|IO.SYS|Log.txt|MSDOS.SYS|NTDETECT.COM|ntldr|pagefile.sys
GETLIST($aLocalList, LOCAL_FILES, "*.MPG")
GETLIST($aRemoteList, REMOTE_FILES, "*.PS")
$aLocalName = ""
$aRemoteName = ""
FOREACH $aFileName IN $aLocalList
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aLocalName = $aLocalName."|".$aName
END FOREACH
FOREACH $aFileName IN $aRemotelist
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aRemoteName = $aRemoteName."|".$aName
END FOREACH
FOREACH $aRemote IN $aRemoteName
$aFound = 0
FOREACH $aLocal IN $aLocalName
IF($aRemote == $aLocal)
$aFound = 1
END IF
END FOREACH
IF($aFound == 0)
GETFILE2($aRemote.".PS", $aRemote.".MPG")
END IF
END FOREACH
GETLIST($aRemoteList, REMOTE_FILES, "*.PS")
$aLocalName = ""
$aRemoteName = ""
FOREACH $aFileName IN $aLocalList
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aLocalName = $aLocalName."|".$aName
END FOREACH
FOREACH $aFileName IN $aRemotelist
$i = TEXTLENGTH($aFileName)
# $aName = $aFileName
# $aExt = ""
WHILE($i > 0)
IF(TEXTCUT($aFileName, $i, 1) == ".")
$aName = TEXTCUT($aFileName, 1, $i-1)
# $aExt = TEXTCUT($aFileName, $i+1, TEXTLENGTH($aFileName)-$i)
$i = 0
END IF
$i = $i-1
END WHILE
$aRemoteName = $aRemoteName."|".$aName
END FOREACH
FOREACH $aRemote IN $aRemoteName
$aFound = 0
FOREACH $aLocal IN $aLocalName
IF($aRemote == $aLocal)
$aFound = 1
END IF
END FOREACH
IF($aFound == 0)
GETFILE2($aRemote.".PS", $aRemote.".MPG")
END IF
END FOREACH
Sorry for my English, I used translate.google.com
- WAndrey
- Posts: 76
- Joined: 24 Dec 2009, 14:28
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests

