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
thanks for the help
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
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######################################################################################
# Folder creation
######################################################################################
:createfolder
$folderpath="D:\files\ZPL"
$foldername=$folderpath."\".GETDATE(FORMAT3)."\"
LOCALMKDIR($foldername)
PRINT(GETTIME(FORMAT0) ."_Created new folder for this day")
SILENT(ON)
Code: Select all
I have something simliar for the logfile and there i can use "getfiletime" and do a textcut to find the day.
########################################################################################
# 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
Code: Select all
This works nice for file but since i need to check the folder dat how can i achive this in scriptftp?$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)
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:
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
I will try this for sure:)
thanks for the different angle of view..... always usefull
have a good weekend..
gr martijn