ask function %CurrentDateTime%.zip

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
FidoGooL
Posts: 1
Joined: 20 Sep 2018, 12:50

ask function %CurrentDateTime%.zip

20 Sep 2018, 13:06

Hello ,

I have one script for upload my wordpress backup to ftp, now this script upload folder.zip on my ftp with name whateverfolder.zip , but need to upload folder.zip and in my ftp need rename folder.zip to %CurrentDateTime%.zip and delete this folder on my pc. :crazy:

Thank you !

Code:

Code: Select all

#SingleInstance
; ===============================================================================================================================
; Upload Files to FTP Server (Server, Username, Password, LocalFile, RemoteFile)
; ===============================================================================================================================

FormatTime, CurrentDateTime,, dd-MM-yyyy-hh_mm_ss tt

FTPUpload(srv, usr, pwd, lfile, rfile)
{
    static a := "AHK-FTP-UL"
    if !(m := DllCall("LoadLibrary", "str", "wininet.dll", "ptr")) || !(h := DllCall("wininet\InternetOpen", "ptr", &a, "uint", 1, "ptr", 0, "ptr", 0, "uint", 0, "ptr"))
        return 0
    if (f := DllCall("wininet\InternetConnect", "ptr", h, "ptr", &srv, "ushort", 21, "ptr", &usr, "ptr", &pwd, "uint", 1, "uint", 0x08000000, "uptr", 0, "ptr")) {
        if !(DllCall("wininet\FtpPutFile", "ptr", f, "ptr", &lfile, "ptr", &rfile, "uint", 0, "uptr", 0))
            return 0, DllCall("wininet\InternetCloseHandle", "ptr", h) && DllCall("FreeLibrary", "ptr", m)
        DllCall("wininet\InternetCloseHandle", "ptr", f)
    }
    DllCall("wininet\InternetCloseHandle", "ptr", h) && DllCall("FreeLibrary", "ptr", m)
    return 1
}

; ===============================================================================================================================

;FTPUpload("ftp.server.com", "ftp.username", "ftppassword", "C:\Users\wp_backup\backup-pensiune.zip", "backup.zip") ;           <<<-------------- here working perfectly
FTPUpload("ftp.server.com", "ftp.username", "ftppassword", "C:\Users\wp_backup\backup-pensiune.zip", "%CurrentDateTime%.zip") ; <<<-------------- this "%CurrentDateTime%.zip" not working :-s

FileDelete, C:\Users\wp_backup\backup-pensiune.zip
msgbox "backup succes" ; Enviro Var 

Guest

Re: ask function %CurrentDateTime%.zip

28 Sep 2018, 02:00

Don't quote "" variables and don't wrap them in %% when using them in function calls, so change it to

Code: Select all

FTPUpload("ftp.server.com", "ftp.username", "ftppassword", "C:\Users\wp_backup\backup-pensiune.zip", CurrentDateTime)
See https://autohotkey.com/docs/FAQ.htm#percent

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Mannaia666, ntepa and 238 guests