AutoHotkey Community

It is currently May 27th, 2012, 3:38 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: how to upload a folder?
PostPosted: July 8th, 2010, 4:10 am 
Offline

Joined: August 3rd, 2009, 9:10 am
Posts: 21
hi,
I used this script from the help file:
Code:
FTPCommandFile = %A_ScriptDir%\FTPCommands.txt
FTPLogFile = %A_ScriptDir%\FTPLog.txt
FileDelete %FTPCommandFile% ; In case previous run was terminated prematurely.

FileAppend,
(
open 192.168.0.1
user
password
binary
cd bak
put c:\pdf\a.pdf
ls -l
quit
), %FTPCommandFile%

RunWait %comspec% /c ftp.exe -s:"%FTPCommandFile%" >"%FTPLogFile%"
FileDelete %FTPCommandFile% ; Delete for security reasons.
Run %FTPLogFile% ; Display the log for review.


it's work,but it only uploaded one file.

how can I upload all files in folder c:\pdf ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2010, 7:00 am 
Code:
mput c:\pdf\*.pdf


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2010, 7:22 am 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
I found that using FTP.ahk yields upload speeds 2 or 3 times faster than the method you used. Although FTP.ahk does not have an mput equivalent, a loop gets it easily done:
Code:
#Include ftp.ahk
server =server.com
port = 21
ID = userID
PW = userPW
hConnect:=FTP_Open(Server, Port, ID, PW)
Loop, C:\pdf\*.*
   { 
   traytip,,uploading %A_LoopFileName%
   FTP_PutFile(hConnect,A_LoopFileFullPath, A_LoopFileName)
   }
FTP_CloseSocket(hConnect)
FTP_Close()
traytip,,done!
sleep, 2000
exitapp

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2010, 10:40 am 
Offline

Joined: August 3rd, 2009, 9:10 am
Posts: 21
thank you , but it doesn't work here, what's wrong?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2010, 5:51 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
Are you trying mput with your original method or the FTP.ahk method. Any error messages?
FYI, I have used FTP.ahk on a number of systems, Vista and XP, and on different connections including having using my Android phone as modem.

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2010, 8:02 am 
Offline

Joined: August 3rd, 2009, 9:10 am
Posts: 21
flyingDman wrote:
Are you trying mput with your original method or the FTP.ahk method. Any error messages?
FYI, I have used FTP.ahk on a number of systems, Vista and XP, and on different connections including having using my Android phone as modem.

thank you flyingDman!

the mput method:
I replaced put with mput:
Code:
FTPCommandFile = %A_ScriptDir%\FTPCommands.txt
FTPLogFile = %A_ScriptDir%\FTPLog.txt
FileDelete %FTPCommandFile% ; In case previous run was terminated prematurely.

FileAppend,
(
open 192.168.0.1
user
password
binary
cd bak
mput c:\pdf\*.pdf
ls -l
quit
), %FTPCommandFile%

RunWait %comspec% /c ftp.exe -s:"%FTPCommandFile%" >"%FTPLogFile%"
FileDelete %FTPCommandFile% ; Delete for security reasons.
Run %FTPLogFile% ; Display the log for review.

then a cmd.exe window popup,and I can't close it.
nothing uploaded.


the FTP.ahk method:
Error:Call to nonexistent function.
Specifically:FTP_Open(Server,Port,ID,PW)
line #
--->006:hConnect:=FTP_Open(Server,Port,ID,PW)
the program will exit.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2010, 9:19 am 
Offline

Joined: March 21st, 2007, 7:50 pm
Posts: 76
zengjia wrote:
then a cmd.exe window popup,and I can't close it.
nothing uploaded.




need to enter "prompt" before mput
to disable the interactive mode
Code:
cd bak
prompt
mput c:\pdf\*.pdf
ls -l


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2010, 4:47 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
Did you download FTP.ahk? Re: standard library; see here:
http://www.autohotkey.com/forum/viewtopic.php?p=335088
to download the library, and here
http://www.autohotkey.com/docs/Functions.htm#lib
to learn about libraries, and here
http://www.autohotkey.com/docs/commands/_Include.htm
to learn about #include

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2010, 2:18 am 
Offline

Joined: August 3rd, 2009, 9:10 am
Posts: 21
kiropes wrote:
zengjia wrote:
then a cmd.exe window popup,and I can't close it.
nothing uploaded.




need to enter "prompt" before mput
to disable the interactive mode
Code:
cd bak
prompt
mput c:\pdf\*.pdf
ls -l


flyingDman wrote:
Did you download FTP.ahk? Re: standard library; see here:
http://www.autohotkey.com/forum/viewtopic.php?p=335088
to download the library, and here
http://www.autohotkey.com/docs/Functions.htm#lib
to learn about libraries, and here
http://www.autohotkey.com/docs/commands/_Include.htm
to learn about #include


thank you very much!!!
2 methods both work!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2010, 9:38 am 
Offline

Joined: August 3rd, 2009, 9:10 am
Posts: 21
hi,need your help again :D
I want to add this code into the script,
rename files on FTP by Date

for example:

rename
ftp://192.168.1.161/a.pdf
to
ftp://192.168.1.161/a-07142010.pdf

Code:
FormatTime, DateString,, MMddyyyy
Loop, ftp://192.168.1.161/*.*
   {
   traytip,,renameing %A_LoopFileName%
   FTP_RenameFile(hConnect,A_LoopFileFullPath, A_LoopFileName-%DateString%)
   }

but it doesn't work. :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2010, 6:20 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
You can not use a "Loop, FilePattern" on files on a FTP site. If you need to loop through remote files use FTP_FindFirstFile and FTP_FindNextFile.
However that does not seem what you need as you asked for renaming a specific file. In that case use:
Code:
server := "server.com", port := "21", ID := "xxx", PW := "yyy"
hConnect:=FTP_Open(Server, Port, ID, PW)
FTP_RenameFile(hConnect,"a.pdf", "a-07142010.pdf")
FTP_CloseSocket(hConnect)
FTP_Close()
return

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2010, 4:36 am 
Offline

Joined: August 3rd, 2009, 9:10 am
Posts: 21
no, I don't want to renaming only one file,
I want to renaming all files on the FTP site by creationtime.
after I got your help ,I tried this:
Code:
server := "192.168.0.1", port := "21", ID := "xxx", PW := "yyy"
hConnect:=FTP_Open(Server, Port, ID, PW)
if((hEnum := FTP_FindFirstFile(hConnect,"*.*", FTPData)))
{
Loop
   {
   FileName := FTP_GetFileInfo(FTPData, "Name")
   CreationTime := FTP_GetFileInfo(FTPData, "CreationTime")
    FTP_RenameFile(hConnect,%filename%, %CreationTime%-%filename%)
if(!FTP_FindNextFile(hEnum, FTPData))
break
   }
}


but failed. :?
error:the following variable name contains an illegal character:
"1/1/1601 0:0:0.0"

I can not use variables?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2010, 4:59 am 
try this:
Code:
server := "192.168.0.1", port := "21", ID := "xxx", PW := "yyy"
hConnect:=FTP_Open(Server, Port, ID, PW)
if((hEnum := FTP_FindFirstFile(hConnect,"*.*", FTPData)))
{
Loop
   {
   FileName := FTP_GetFileInfo(FTPData, "Name")
   CreationTime := FTP_GetFileInfo(FTPData, "CreationTime")
    FTP_RenameFile(hConnect, filename, %CreationTime%-%filename%)
if(!FTP_FindNextFile(hEnum, FTPData))
break
   }
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2010, 7:50 am 
Offline

Joined: August 3rd, 2009, 9:10 am
Posts: 21
Z_Gecko wrote:
try this:
Code:
server := "192.168.0.1", port := "21", ID := "xxx", PW := "yyy"
hConnect:=FTP_Open(Server, Port, ID, PW)
if((hEnum := FTP_FindFirstFile(hConnect,"*.*", FTPData)))
{
Loop
   {
   FileName := FTP_GetFileInfo(FTPData, "Name")
   CreationTime := FTP_GetFileInfo(FTPData, "CreationTime")
    FTP_RenameFile(hConnect, filename, %CreationTime%-%filename%)
if(!FTP_FindNextFile(hEnum, FTPData))
break
   }
}

:?
error:the following variable name contains an illegal character:
"1/1/1601 0:0:0.0"
the current thread will exit.
line#
-->010:FTP_RenameFile(hConnect, filename, %CreationTime%-%filename%)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2010, 7:03 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
try:
Code:
    FTP_RenameFile(hConnect, filename, CreationTime . "-" .  filename)

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, Google Feedfetcher, Wicked, Yahoo [Bot] and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group