Jump to content
Sign in to follow this  
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jahar
      Hi All,
      Please help me on how to fetch date/time of last windows 10 system restore point using autoit? Basically its about querying the last restore point.
    • By TheDcoder
      Hi everyone,
      I am bit stumped as to why I am not able to set the time in the Date control
      #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI get date", 200, 200, 800, 200) Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20, $DTS_TIMEFORMAT) ; to select a specific default format Local $sStyle = "HH:mm:ss" GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle) ; Set time Local $iRet = GUICtrlSetData($idDate, '13:33:37') ConsoleWrite('GUICtrlSetData returned ' & ($iRet = 1 ? 'success' : 'failure') & @CRLF) GUISetState(@SW_SHOW) ; Loop until the user exits. While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate)) EndFunc ;==>Example The documentation for GUICtrlSetData clearly mentions that it uses the same format as GUICtrlRead:
      But I get failure
      What gives?
      Thanks for the help in advance!
    • By Colduction
      Hi guys, i want to convert WebKit/Chrome timestamps that i've found in chrome cookie database to Human-Readable time (if possible, with UTC or GMT offset).
      Example of WebKit/Chrome timestamp: 13228999534132232 Output that i want: 2020-03-18 20:16:56 This site has a tool to do this work, but i wonder how to convert this time (this timestamp's time bases are 1600/01/01) to human-readable time:
      https://www.epochconverter.com/webkit
×
×
  • Create New...