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.
Post here if you experience file transfer problems or unexpected errors.
Hello all,

I have a script which needs to created a folder for each day that it runs.
That part works perfect see code below
Code: Select all###################################################################################### # Folder creation ###################################################################################### :createfolder $folderpath="D:\files\ZPL" $foldername=$folderpath."\".GETDATE(FORMAT3)."\" LOCALMKDIR($foldername) PRINT(GETTIME(FORMAT0) ."_Created new folder for this day") SILENT(ON)  
But since this scripts runs always i need to build in a check if the folder is from today and when it's not from today ->create a new folder
Code: Select all######################################################################################## # Check if folder is from today, when not, create new ######################################################################################## :checkfolderdate LOGTO($logfile,APPEND) $current_day=GETDATE(FORMAT3) ??????????????? IF($????==$current_day)  PRINT(GETTIME(FORMAT0) ."_Folder is from today.")  STOPLOG()  GOTO :next step ELSE  PRINT(GETTIME(FORMAT0) ."_Folder is from yesterday.")  STOPLOG()  GOTO :createfolder END IF
I have something simliar for the logfile and there i can use "getfiletime" and do a textcut to find the day.
Code: Select all$current_day=GETDATE(FORMAT3) $file_last_modification_time=GETFILETIME(LOCAL,$logfile) $file_last=TEXTCUT($file_last_modification_time,9,2) IF($file_last==$current_day)
This works nice for file but since i need to check the folder dat how can i achive this in scriptftp?

thanks for the help
Hi Marty,

As the folder name depends on the date you have created it, try checking if the folder exists instead. To check it you have to do something like this:
Code: Select all$foldername=$folderpath."\".GETDATE(FORMAT3)."\" # Get the remote directory listing, store it in $list GETLIST($list,LOCAL_DIRECTORIES) # Check if the directory exist $found="FALSE" FOREACH $item IN $list  IF($item==$foldername) $found="TRUE"  END IF END FOREACH IF($found) # do something ELSE # do something different END IF
That indeed is a very creative solution :)

I will try this for sure:)

thanks for the different angle of view..... always usefull
have a good weekend..

gr martijn