Jump to content
Jemboy

Change file time en date on FTP-server

Recommended Posts

Hi,

Ones(some times twice) a month I get an e-mail with zip file, which has price updates from a supplier.
I have to upload the file to an FTP to get it processed.

When uploading the file, it will get "timestamped" with the time and date at which time the file was uploaded.
Normally this is fine, because I mostly upload the file the same day.
Sometimes it may take 1 or 2 days before I can upload the file.

For historical purpose, I would like to have the file timestamped with the original date.

I have tried using:  _FTP_Command ( $hFTPSession, "MFCT YYYYMMDDHHMMSS path") 

however this command does not work or change the timestamp as I expected.

Does anyone now a way how I can change the timestamp of a FTP-file?

Share this post


Link to post
Share on other sites

@Jemboy
Does the function return any error? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Can you please post the whole code, and, maybe, adding @error checking to the other _FTP* functions too, in order to see if there are any errors before you use this function? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Hi Francesco, it took me some time because I wanted to post a working testcode with a live ftp-server to trouble shoot.

On the FTP server, I first tested the _FTP_Command function with some basic server functions like e.g. PWD.
After getting non-error result I new suspected that my code was valid, but that the MFCT command was not working.

With Google I found out, that not alll time-date FTP command work on every server, so I started checking the time command I found at:
https://en.wikipedia.org/wiki/List_of_FTP_commands with some info from: https://support.solarwinds.com/Success_Center/Serv-U_Managed_File_Transfer_Serv-U_FTP_Server/Knowledgebase_Articles/MFMT_FTP_command 

Testing with _FTP_Command ( $Conn, "MFMT YYYYMMDDHHMMSS file")  resulted into the  file time and dated being changed.

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <FTPEx.au3>
#include <Array.au3>

Local $server = "185.182.57.118"
Local $username = "autoit@testweb.nl"
Local $pass = "P w T e s t 2 0 1 8"

Local $Open = _FTP_Open('MyFTP Control')
Local $Conn = _FTP_Connect($Open, $server, $username, $pass,1)

; Get FTP files with extended data - Return files (2), $INTERNET_FLAG_NO_CACHE_WRITE (0) and date formatted: mm/dd/yyyy (0)
Local $aFile = _FTP_ListToArrayEx($Conn, 2,0,0)

; change the date if WIL05016.080 in the current ftp dir, date format = YYYYMMDDHHMMSS
; see also: https://support.solarwinds.com/Success_Center/Serv-U_Managed_File_Transfer_Serv-U_FTP_Server/Knowledgebase_Articles/MFMT_FTP_command
$ResrFC = _FTP_Command ( $Conn, "MFMT 20180102110101 WIL05016.080")  ; use MFMT and not MFCT

_ArrayDisplay ($aFile,"FTP Test")

Local $Ftpc = _FTP_Close($Open)

By removing the spaces between the letters in $pass, the code should be 100% working (until I disable the FTP-server).
The time and date of WIL05016.080 should be 09/05/2018, but has been changed after running the code to: 01/02/2018.

When uploading a file to FTP-server, it usually gets the current date and time.
If some how you want to preserve e.g. the existing filedate, you might use the MFTM command after uploading files.

 

 

Edited by Jemboy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By Simpel
      Hi,
      I wanted to use _GetLogonTime() by guinness (https://www.autoitscript.com/forum/topic/19370-autoit-wrappers/?do=findComment&comment=942069).
      #include <Date.au3> #include <Array.au3> ConsoleWrite(_GetLogonTime() & @LF) Func _GetLogonTime($sUserName = @UserName, $sComputerName = @ComputerName) ; Idea by trancexx: http://www.autoitscript.com/forum/topic/113611-if-isadmin-not-detected-as-admin/ Local $aRet = DllCall("netapi32.dll", "long", "NetUserGetInfo", "wstr", $sComputerName, "wstr", $sUserName, "dword", 11, "ptr*", 0) _ArrayDisplay($aRet) If @error Or $aRet[0] Then Return SetError(1, 0, False) Local $sHours = DllStructGetData(DllStructCreate("ptr;ptr;ptr;ptr;dword;dword;dword;ptr;ptr;dword;dword;dword;dword;ptr;dword;ptr;dword;dword;byte;dword", $aRet[4]), 18) DllCall("netapi32.dll", "long", "NetApiBufferFree", "ptr", $aRet[4]) Return _DateAdd("h", "-" & $sHours, _NowCalc()) EndFunc ;==>_GetLogonTime It always returns false.
      I displayed $aRet:
      [0]|2221
      [1]|mycomputer
      [2]|myuser
      [3]|11
      [4]|0x0000000000000000
      $aRet[4] shouldn't be 0x0000000000000000 right? Any help?
      Regards, Conrad
       
    • By Jeep
      Here is an other UDF for string handling :
      Date handling
      _StringDateConvert:  convert a date from one format ("YMD", "MDY" or "DMY") to another.
      _StringIsDate:  checks if a date with a given format is valid
      String management
      _StringCount: count of occurrences that appear in a string
      _StringFormatBytesSize: formatting a dimension expressed in bytes (bytes) in MB, TB, ...)
      _StringIsEndingWith: check if a string end with some characters
      _StringIsStartingWith: check if a string start with some characters
      _StringJoinArray:  concatenate elements of an array to rebuild a string
      _StringPadLeft: filling a string with characters on the left
      _StringPadRight: fill a string with characters on the right
      _StringRemoveFrenchAccent: remove french accent
      _StringRemoveChars: deleting characters from a string
      _StringStrip: eliminate characters at the begin and/or at the  end of a string
      _StringTitleCaseFrench: capitalize the first letter of each word with elimination of french accents
      _StringWSClean: simple replacement of "White Spaces",  remove beginning and trailing spaces and multiple spaces removal
      Any comments, suggestions for improvement or constructive criticism are welcome.
      Below you will find the UDF and a demo program. 
       
       
      JPD_String.zip
    • By Skeletor
      Hey All,
      I'm trying to set the date using a variable.
      Basically, I set the date into the input box, then I change the input box, say, I change the year.
      Then I set what I typed into the input box into the Date Picker.

      This is a demo code.
      #include <ButtonConstants.au3> ;Start GUI includes #include <EditConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <GuiDateTimePicker.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $Date1 = GUICtrlCreateDate("2019/02/02 23:16:26", 80, 64, 186, 21, $DTS_SHORTDATEFORMAT) $Input1 = GUICtrlCreateInput("Input1", 80, 152, 185, 21) $Button1 = GUICtrlCreateButton("Set data", 176, 96, 75, 25) $Button2 = GUICtrlCreateButton("Read from input", 176, 200, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Read = GUICtrlRead($Date1) GUICtrlSetData($Input1, $Read) MsgBox(-1, "", $Read) Case $Button2 $Read = GUICtrlRead($Input1) $New_date = StringReplace($Read, "/", "") $DAY = StringLeft($New_date, 2) $MON = StringMid($New_date, 4, 3) $YEAR = StringRight($New_date, 4) MsgBox(-1, "", $DAY & $MON & $YEAR) ;_GUICtrlDTP_SetFormat($hWndDate, "yyyy/MM/dd") $DateFormate = ($DAY & " " & $MON & " " & $YEAR) $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW GUICtrlSendMsg($Date1, $DateFormate, 0, "MM/dd/yyyy") EndSwitch WEnd  
×
×
  • Create New...