AutoHotkey Community

It is currently May 27th, 2012, 12:50 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: July 16th, 2011, 1:54 am 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
Absolutely new here. Hi reader.
I want to copy a number of files from some place to a new place, hard disk, pens, cards, all within same computer hardware, no network. The copy order must follow a list, no random or offset sequence.

Files must not be opened.

I guess I need 2 main commands. What are these and how are they applied?

using AutoHotkey_L_Install.exe (I want the UTF-8 ability),
and trying to figure out it running in "interpreted mode" to see how my program behaves when stepped.

The 2 commands COPY FROM / PASTE TO are the core for my application,
IF EXIST;CONTINUE;ELSE QUIT:

Looking forward to continue.


WinXPh SP3


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2011, 9:11 am 
I'd store the list of files to copy in a text file, read the text file using http://www.autohotkey.com/docs/commands/FileRead.htm use a http://www.autohotkey.com/docs/commands/LoopParse.htm and use the info to http://www.autohotkey.com/docs/commands/FileCopy.htm


Report this post
Top
  
Reply with quote  
PostPosted: July 17th, 2011, 2:16 am 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
come closer, I want to embrace you! You just don't know how many sources (mainly BASIC) I checked and did not get anywhere. In this community my first question's response is a HIT.
I'll continue, looking forward to the fun of AutoHotkey. Thanks.

Added later
I am splitting the development into modules. Here are the modules I am working on in parallel:
GUI and string handling.
GUI text input
GUI multiple text boxes and entry fields, Preferences window
GUI with file path analysis
GUI background and text appearance
File copy from / to with overwrite control
Checking for empty folder (coming up)
Loop file copy process with Stop sign (coming up)
Date added: W 30; Sun, 2011.07.31; 16:59:51

Other threads related to the same project
FONTS AND COLORS - where are full instructions http://www.autohotkey.com/forum/viewtopic.php?p=463149#463149
ARRAY WRITE READ; DATA FROM, DISPLAY / WRITE to
http://www.autohotkey.com/forum/viewtopic.php?p=463577#463577
_________ updated W 31; Wed, 2011.08.3; 17:36:07 ___________


Last edited by morphingstar on August 3rd, 2011, 11:37 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 19th, 2011, 3:38 am 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
http://www.autohotkey.com/docs/commands/FileCopy.htm
AHK Examples
COPY / PASTE function for files
FileCopy, C:\My Documents\List1.txt, D:\Main Backup\ ; Make a copy but keep the orig. file name.
FileCopy, C:\My File.txt, C:\My File New.txt ; Copy a file into the same folder by providing a new name.
FileCopy, C:\Folder1\*.txt, D:\New Folder\*.bkp ; Copy to new location and give new extension.

???
Command modification:
How do I replace the file name by a string previously read from an "array" inside the Copy / Paste loop.
"List1.txt" as shown above should be a string variable.
"C:\Folder1\" as shown above should be a string variable. (Set in a Preferences window.)
-----------------------------------
http://www.autohotkey.com/docs/misc/Arrays.htm
I guess this might work with a multi-column csv file.

WinXPh SP3


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2011, 4:35 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
Hi morphingstar, welcome to the forum.

I suggest working throught the quick-start tutorial, it will help with the terminology that is used in the forum
http://www.autohotkey.com/docs/Tutorial.htm

The command has 3 paramters, the first 2 are expected to be literal strings.
FileCopy, SourcePattern, DestPattern [, Flag]

FileCopy, C:\My Documents\List1.txt, D:\Main Backup\

In place of the literals you can use the contents of a variable

Code:
SourcePattern = C:\My Documents\List1.txt
DestPattern = D:\Main Backup\
FileCopy, %SourcePattern%, %DestPattern%


I suggest you review the documentation here
http://www.autohotkey.com/docs/Variables.htm#Variables


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 23rd, 2011, 5:23 am 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
thanks, I had already read the Tutorial; did not come across the Variables page then. It looks I can start programming now.

_________________
WinXPh SP3. AutoHotkey.exe, Application, AutoHotkey_L, 854 KB (875'008 bytes), 30. April 2011, 23:06:30, Version 1.1.0.0,


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 23rd, 2011, 9:06 pm 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
While I am very early in my 1st steps of AHK programming, I wonder how portable the resulting *.exe is. For me it would be ideal if it run in JAVA, on many O/S.
I suspect that many of potential users are using Linux. It looks to me I can not run my Windows based AHK *.exe in Linux.
??

_________________
WinXPh SP3. AutoHotkey.exe, Application, AutoHotkey_L, 854 KB (875'008 bytes), 30. April 2011, 23:06:30, Version 1.1.0.0,


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 23rd, 2011, 9:25 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
>>For me it would be ideal if it run in JAVA, on many O/S.

Then it would be Java, not AutoHotkey :roll:

>>I suspect that many of potential users are using Linux. It looks to me I can not run my Windows based AHK *.exe in Linux.

I've never tried it but you could check here http://www.ironahk.net/

I just noticed that the iron ahk "forum" link seems to be not working properly.

Here's a little more information
http://www.autohotkey.com/forum/viewtop ... sc&start=0

perhaps you can PM/email polyethene


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 24th, 2011, 5:37 pm 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
Code:
SourcePattern = C:\My Documents\List1.txt
DestPattern = D:\Main Backup\
FileCopy, %SourcePattern%, %DestPattern%


From what I see SourcePattern is a variable, I could not find it as a command, but may have missed it. Just to ascertain.

=================================

Main program in development: CONTROLLED FILE COPIER (not started)
MODULE IN DEVELOPMENT: FILE PATH CORRECTION / CONFIRMATION WINDOW
Questions:
1) How can I have and use more then one string input field before OK is to be pressed? Only the last one gets displayed to see. I need 4.
2) Input fields in GUI sections
2a) Why can vEditBox and %EditBox% not be replaced by a different variable name {vS_path, S_path}?
2b) Why can vFixEditBox and %FixEditBox% not be replaced by a different variable name {vD_path, D_path}?
3) Go: Go1, Go2, Go3 etc. Why is the first lot of lines without a "Go". There appears to be no subroutine call to Go2, Go3. Where can I learn about sructuring AHK?
4) Data Transfer from one to other variable. Why is this not happening when command is located before Return where there would be a "natural" location. Or how can I do the transfer before the next subroutine is called, to free the Entry-Field variable (vEditBox)
5) I received error message saying I can not use a variable twice (lines listed). The variable appeared only once in the program. Where was the second? Error eliminated without knowing what it really was.
________________



Code:
;Main Program, in development: _Controlled File Copier_
;Sub-Program: File directory handling / interface (Part of Preferences window)
;Author: Alias morphingstar
; Generated using SmartGUI Creator 3.5.1, edited in NoteTab.
;Next small goal: Open window Preferences, enable user to accept / correct 3 file directories using the OK-button.
;Micro-goals: Improve string handling as commented in this program.
;_________ Commands as recommended in forum
#NoEnv 
#notrayicon
#SingleInstance force
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;______
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. Added for convenience, not used for stated purpose.
;
;_________Variable data assignment
Editbox = G:\_workfiles\source
FixEditbox = G:\_workfiles\destination
;String handling to be added to replace drive G: by the AHK containing drive (e.g. SD card / USB_pen.
;_________Program start using GUI
;structure copied from http://www.autohotkey.com/forum/viewtopic.php?p=51911#51911
;Go0:
;Gui, 0:Submit
;
Gui, 1:Add, Text, x16 y7 w100 h30,(1)_Enter file source directory
;Gui, 1:Add, Edit, x136 y7 w200 h30 vEditbox, G:\_workfiles\source
Gui, 1:Add, Edit, x136 y7 w200 h30 vEditbox, %Editbox%
; Is _Editbox_ a command AND a variable? Prg turned bad when EDITBOX was replaced by S_path.
Gui, 1:Add, Button, gGo1 x16 y57 w100 h30,Go
;  Note the Go1 versus Go2, is this a variable than can not be used twice?
Gui, 1:Add, Button, x136 y57 w100 h30,Cancel
Gui, Show, x158 y110 h107 w358, 1 Window Top ez using ;SmartGUI Creator 3.5.1
;FileSourceDir = %Editbox%
Return

;Go2:
;Gui, 2:Submit
Go1:
Gui, 1:Submit
Gui, 2:Add, Text, x16 y7 w100 h30,Confirm or change file Destination
;Gui, 2:Add, Edit, x136 y7 w200 h30 vFixEditbox, G:\_workfiles\destination
Gui, 2:Add, Edit, x136 y7 w200 h30 vFixEditbox, %FixEditbox%
; Is _FixEditbox_ a command AND a variable? Prg turned bad when FIXEDITBOX was replaced by D_path.

Gui, 2:Add, Button, gGo2 x16 y57 w100 h30,Go
;  Note the Go2 versus Go1, is this a variable than can not be used twice?
Gui, 2:Add, Button, x136 y57 w100 h30,Cancel
Gui, 2:Show, x158 y110 h107 w358, 2 Window Top ez using SmartGUI Creator 3.5.1
;FileDestDir = %FixEditbox%
return

;Go3:
Go2:
Gui, 2:Submit

;_____________ variable data transfer / copy (purpose: test operation)
FileSourceDir = %Editbox%
FileDestDir = %FixEditbox%


msgbox, FROM %filesourcedir% TO %FileDestDir% -Full path %A_ScriptDir%
;Chr$(13) won't CR
return

Cancel:
Gui, Cancel
return

;Killing variable content for this program because of supposed double use
FixEditbox = ""
Editbox = ""
FileSourceDir = ""
FileDestDir = ""
return


ExitApp



thanks

_________________
WinXPh SP3. AutoHotkey.exe, Application, AutoHotkey_L, 854 KB (875'008 bytes), 30. April 2011, 23:06:30, Version 1.1.0.0,


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2011, 5:48 pm 
Q: String handling to be added to replace drive G: by the AHK containing drive (e.g. SD card / USB_pen
A: http://www.autohotkey.com/docs/commands/SplitPath.htm

Q: Is _Editbox_/_FixEditbox_ a command AND a variable? Prg turned bad when EDITBOX was replaced by S_path
A: No, Editbox/_FixEditbox_ are names of variables: vEditbox, v stands for Variable

Q: Note the Go1 versus Go2, is this a variable than can not be used twice?
A: Go1 and Go2 are NOT variables, they are LABELS, g stands for Gosub/Goto Label


Report this post
Top
  
Reply with quote  
PostPosted: July 29th, 2011, 9:56 pm 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
http://www.autohotkey.com/docs/commands/SplitPath.htm

Thanks, I spent 2-3 hours trying to get a result from using the examples shown on that web page.
Result = 0.

I would like to display where the *.ahk file sits, at a later date the related *.exe.

Some of my trials are recorded in the program, starting with ";".
Some are active, producing nothing usable.

Where is the "knot" ?

Code:
#NoEnv
#notrayicon
#SingleInstance force
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;SplitPath, InputVar [, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive]
;________________Discover where this program sits
;SetWorkingDir %A_ScriptDir%
;SplitPath, FullFileName, name, dir, ext, name_no_ext, drive
vprg_dir:=SplitPath, FullFileName, name
SplitPath, FullFileName, name, dir, ext, name_no_ext, drive

prg_dir=SplitPath, FullFileName,, dir
Gui, Add, Text, x50 y40 w280 h50 , Discover where this program sits

;
;http://de.autohotkey.com/forum/topic2391.html&highlight=dateipfad+anzeigen
;Splitpath, Bild, Filename
;GuiControl, , Bild, %Filename%
;
Splitpath,FullFileName,Filename
;next line from German AHK forum, different goal
;GuiControl, , ,%Filename%
Gui, Add, Text, x50 y140 w280 h50 , %FileName%
Gui, Add, Text, x50 y240 w280 h50 , name_no_ext
Gui, Add, Text, x50 y340 w280 h50 , prg_dir
Gui, Add, Text, x50 y440 w280 h50 , vprg_dir
;
; None of the varable shows the path or part of
;no entry box required, no EditBox
;a label box will be done later, seems simple.


;Gui, Add, Text x50 y550 w300 h20, vdir , dir

;, name, dir, ext, name_no_ext, drive
;Gui, Add, Text, x50 y600 w200 h20 , vprg_dir

;Gui, Add, Text, x200 y600 w200 h20 , %A_ScriptDir%

; Generated using SmartGUI Creator 4.0
Gui, Show, x160 y180 h650 w500, Program File Path Display
Return

GuiClose:
ExitApp

_________________
WinXPh SP3. AutoHotkey.exe, Application, AutoHotkey_L, 854 KB (875'008 bytes), 30. April 2011, 23:06:30, Version 1.1.0.0,


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 29th, 2011, 10:23 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
>>vprg_dir:=SplitPath, FullFileName, name
>>SplitPath, FullFileName, name, dir, ext, name_no_ext, drive
>>prg_dir=SplitPath, FullFileName,, dir

In all of the above, the variable FullFileName is never assigned a value. There is therefore nothing to split.

The lines where you use := or = are incorrect, SplitPath is a command, not a function

Proper usage is shown in the documentation http://www.autohotkey.com/docs/commands/SplitPath.htm



morphingstar wrote:
I would like to display where the *.ahk file sits, at a later date the related *.exe.


Do you mean the location of the AHk file you are running ?

If so, look at these variables related to Script Properties http://www.autohotkey.com/docs/Variables.htm#prop
A_ScriptDir A_ScriptName A_ScriptFullPath
A_IsCompiled

Code:
msgbox %A_ScriptDir%`r%A_ScriptName%`r%A_ScriptFullPath%


Code:
---------------------------
junk1682.exe
---------------------------
C:\Users\Leef_me\Documents\Autohotkey
junk1682.exe
C:\Users\Leef_me\Documents\Autohotkey\junk1682.exe
---------------------------
OK   
---------------------------


Btw, I get exe vs ahk extension depending on whether compiled or not.
And the variable "A_IsCompiled" is useful too.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 31st, 2011, 5:56 pm 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
A_ScriptFullPath
at
http://www.autohotkey.com/docs/Variables.htm#prop
I read it as defining the path.
What I was looking for is reading the path, then extract the desired parts.


Quote:
Proper usage is shown in the documentation http://www.autohotkey.com/docs/commands/SplitPath.htm

This was my source, when I could not use it (no result) I came here.
I use the *.ahk script file for learning to handle file path's, convenience.
Quote:
variable FullFileName is never assigned a value

Why, where did I go wrong, what did I not put in program? I realized the was nothing in any of the variable I used like
Quote:
prg_dir=SplitPath, FullFileName,, dir

and could not find why.
Quote:
msgbox %A_ScriptDir%`r%A_ScriptName%`r%A_ScriptFullPath%

What is the `r doing?
Thanks.

_________________
WinXPh SP3. AutoHotkey.exe, Application, AutoHotkey_L, 854 KB (875'008 bytes), 30. April 2011, 23:06:30, Version 1.1.0.0,


Last edited by morphingstar on July 31st, 2011, 10:18 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 31st, 2011, 6:14 pm 
Offline

Joined: July 15th, 2011, 11:49 pm
Posts: 52
I got the file copy from / to working.
Overwrite control did not work when I followed the examples offered on AHK.
http://www.autohotkey.com/docs/commands/FileCopy.htm
Please advise why the examples do not work.
If they are wrong, please try have them corrected or tell me where to report it.

In the code I first tried simply copying. (commands are ";")
Once it worked for me I checked how to control file overwrite.
Lines commented with ";" are either test lines which did not work or real comments. Explanations are inside the code.


Code:
#NoEnv
#notrayicon
#SingleInstance force
SendMode Input 
;http://www.autohotkey.com/docs/commands/FileCopy.htm
;FileCopy, SourcePattern, DestPattern [, Flag]
;functionally identical examples:
;FileCopy, C:\*.txt, C:\My Folder 
;FileCopy, C:\*.txt, C:\My Folder\*.*
; path
;J:\Documents\_workfiles\LxFrom
;J:\Documents\_workfiles\LxTo
;file names:
;Anhelo.mid, lluvia.mid, la paloma.mid
; Example: FileCopy, C:\My Documents\List1.txt, D:\Main Backup\  ; Make a copy but keep the orig. file name.
;
;Example modified: FileCopy, J:\Documents\_workfiles\LxFrom\List1.txt, J:\Documents\_workfiles\LxTo 
; next 3 lines operational if un-commented
;FileCopy, J:\Documents\_workfiles\LxFrom\Anhelo.mid, J:\Documents\_workfiles\LxTo 
;FileCopy, J:\Documents\_workfiles\LxFrom\lluvia.mid, J:\Documents\_workfiles\LxTo 
;FileCopy, J:\Documents\_workfiles\LxFrom\la paloma.mid, J:\Documents\_workfiles\LxTo 
;above works
;
;overwrite handling
;FileCopy, SourcePattern, DestPattern [, Flag]
;0 = (default) do not overwrite existing files, 1 = overwrite existing files
;CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false)
;FileCopy, %SourcePattern%, %DestinationFolder%, %DoOverwrite%
;use text file to alter modification date time, not alter file name. check time to see if overwritten, use 1 file.
; try 2 variables, 1 as AHK recommends, other following my own logic. Useless version will be / was Commented after test.
vDoOverwrite = true
;DoOverwrite = true
;FileCopy, J:\Documents\_workfiles\LxFrom\text1.txt, J:\Documents\_workfiles\LxTo   
;FileCopy, J:\Documents\_workfiles\LxFrom\text2.txt, J:\Documents\_workfiles\LxTo
;FileCopy, J:\Documents\_workfiles\LxFrom\text3.txt, J:\Documents\_workfiles\LxTo, %DoOverwrite%
; DoOverwrite works in no fashion of 2 variables tried
FileCopy, J:\Documents\_workfiles\LxFrom\text3.txt, J:\Documents\_workfiles\LxTo, 1
; with the number "1" in place of variable, command works. Error is in variable operation.
; try this
FileCopy, J:\Documents\_workfiles\LxFrom\text3.txt, J:\Documents\_workfiles\LxTo, DoOverwrite
; this works, meaning the example on AHK website is wrong
; figuring out which "variable" was efficient: vDoOverwrite = true or DoOverwrite = true
; as expected by me, the DoOverwrite = true is useless, though recommended on AHK website. So is the %variable%, which is questionable.
;
;
ExitApp
;



end of: FileCopy wrong examples - pls check

_________________
WinXPh SP3. AutoHotkey.exe, Application, AutoHotkey_L, 854 KB (875'008 bytes), 30. April 2011, 23:06:30, Version 1.1.0.0,


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 31st, 2011, 8:13 pm 
Offline

Joined: April 4th, 2008, 8:15 pm
Posts: 538
Location: Canada
Code:
FileAppend SomeText, File1.txt
FileAppend SomeOtherText, File2.txt

Overwrite := True
Overwrite2 = True

;FileCopy File1.txt, File2.txt, %OverWrite% ;This will work
FileCopy File1.txt, File2.txt, %OverWrite2% ;This will not work


Also, your code without comments
Code:
vDoOverwrite = true

FileCopy, J:\Documents\_workfiles\LxFrom\text3.txt, J:\Documents\_workfiles\LxTo, 1
FileCopy, J:\Documents\_workfiles\LxFrom\text3.txt, J:\Documents\_workfiles\LxTo, DoOverwrite
ExitApp


I'm guessing the reason it worked in the AHK example was because they used a function, here's an example:

Code:
funct()
funct(x=false){
Msgbox %x% ;boolean false
}


x=false
Msgbox %x% ;literal 'false'


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, jrav, MSN [Bot] and 20 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