Archives
- July 2019
- January 2019
- November 2018
- August 2018
- July 2018
- February 2018
- November 2017
- October 2017
- July 2017
- June 2017
- May 2017
- April 2017
- January 2017
- December 2016
- November 2016
- August 2016
- January 2015
- December 2014
- March 2014
- April 2013
- December 2010
- November 2009
- September 2009
- June 2009
- March 2009
- February 2009
- November 2008
- October 2008
- August 2008
- July 2008
- January 2008
How to create a local folder using the current date
23rd October 2017Dates can be written in multiple ways, not only because of the language used (English, Spanish, German…) but also within the same language we can write a date in many different ways. For example in English, we can write it as “20 October 2017”, 20/10/2017, 10/20/2017 etc.
In ScriptFTP the most common formats of dates are available in the GETTIME command but sometimes you need to retrieve the date or time components separately (month, day, year, hour…) and build your own expression of a date or time. In this example, it is shown how to build a date expression without spaces and using a three letter month, for example “20Jan2017”. We will then use it to create a local directory.
# Set the current local directory to C:\mycurrent_dir LOCALCHDIR("c:\mycurrent_dir\") # Get the current day, month and year as numbers $day_number = GETTIME(DAY) $month_number = GETTIME(MONTH) $year_number = GETTIME(YEAR) # Build the 3 letter month name based on the # month number $month_text = "" IF($month_number=="1") $month_text = "Jan" END IF IF($month_number=="2") $month_text = "Feb" END IF IF($month_number=="3") $month_text = "Mar" END IF IF($month_number=="4") $month_text = "Apr" END IF IF($month_number=="5") $month_text = "May" END IF IF($month_number=="6") $month_text = "Jun" END IF IF($month_number=="7") $month_text = "Jul" END IF IF($month_number=="8") $month_text = "Aug" END IF IF($month_number=="9") $month_text = "Sep" END IF IF($month_number=="10") $month_text = "Oct" END IF IF($month_number=="11") $month_text = "Nov" END IF IF($month_number=="12") $month_text = "Dec" END IF # Build the folder name. It will lool like 12Oct2017 $foldername = $day_number.$month_text.$year_number # Run the windows mkdir command, not the one from ScriptFTP # to create a local directory. The MKDIR command from ScriptFTP # is used to create remote directories. The LOCALMDKDIR command # from ScriptFTP can be also used to create a local directory. EXEC("mkdir ".$foldername)