ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Need help writing a script? Have any question about ScriptFTP?
I have a script that creates new directories based on the file created date, year and month (200901, 200902,200903, etc) when it downloads the file from the remote directory. It then deletes the files off of the remote directory.

I would like to add a log file for each directory on my local server(200901, 200902,200903, etc) that logs all the files currently in it. I'd like to onclude the path if possible.

I'm thinking everytime it downloads files to that directory it would append the log. Do you have any suggestions on how I can do this so it also backtracks the directories that will not have future downloads?
Hello,

You can create custom log files with a small trick: using EXEC to run the windows command "echo". This windows command is useful to create text files. For example, open your windows command line and type the following:
echo some text here >> mytextfile.txt
This will create a text file called mytextfile.txt (if it does not exist) and append the text "some text here". It will also add a line break.

So, in ScriptFTP, you can do the same thing this way:
Code: Select all$directory="C:\mydir\downloads\200901" $downloaded_file=$directory."\thefile.zip" # This will make ScriptFTP to run this windows command: # echo C:\mydir\downloads\200901\thefile.zip >>  C:\mydir\downloads\200901\logfile.txt EXEC("echo ".$downloaded_file." >> ".$directory."\logfile.txt")
You have to change this example a bit in order to get the correct file name and path.
Thank you very much. I think this will work. Can you look over my script and see if I placed the EXEC command in the proper section?
Code: Select all# Connect to FTP server $result=OPENHOST("ftp.mysite.com","ftpuser","ftppw") IF($result=="OK")     CHDIR("/vox")     GETLIST($list,REMOTE_FILES)     FOREACH $item IN $list         # Make sure we stop transfering at 5:00AM         IF (GETDATE(HOUR)=="05")             CLOSEHOST             STOP         END IF         $time=GETFILETIME(REMOTE,$item)         $myyear=TEXTCUT($time,1,4)         $mymonth=TEXTCUT($time,6,2)         $mysubdir=$myyear.$mymonth         if ($myyear>="2009")             LOCALMKDIR("D:\Strata_Audio\".$mysubdir)             LOCALCHDIR("D:\Strata_Audio\".$mysubdir)             print($item)             print($time)             print($mysubdir)             $result_getfile=GETFILE($item)                         # If the file has been downloaded successfully             # delete the remote copy. Else stop the script.             IF($result_getfile=="OK")          DELETEFILE($item)             # This will make ScriptFTP to run this windows command:             # echo each item downloaded into its own subdirectory's logfile.             EXEC("echo ".$item." >> ".$mysubdir."\".$mysubdir."logfile.txt")             END IF         END IF     END FOREACH     CLOSEHOST END IF
It seems to be correct. You append the file path only if the download was successful and after deleting the remote file.
Thanks. I tried it on another script and it works like a charm. Thanks. The script above I can only test after production hours.

Thanks for your help.