Well I spent a good 2 hours trying to figure out how the hell to have autohotkey copy a file to another directory, while renaming it with a prefix each time win+c is pressed. I imagined having autohotkey add a prefix to the name of the file copied to the new folder such as:
record01.dem
record02.dem
record03.dem
record04.dem ..etc
Here is my first failed attempt, but it's the closest I got to getting this to work:
Code:
*#c::FileCopy, C:\Program Files\Steam\steamapps\chief_ace\counter-strike source\cstrike\record.dem, C:\Documents and Settings\USER\Desktop\demos\record*.dem
I tried using the integer variable, but I couldn't get it working. Then I tried arrays, and well, I had the same problem only that I was even far more confused, but I think I'm supposed to be using arrays to have autohotkey add a prefix? Do I have the script retrieve the latest number from a txt?
Here is my attempt at using the FileCopyFolders, editing the example provided in the help html:
Code:
ErrorCount := CopyFilesAndFolders("C:\Program Files\Steam\steamapps\chief_ace\counter-strike source\cstrike\record.dem", "C:\Documents and Settings\USER\Desktop\demos\")
if ErrorCount <> 0
MsgBox %ErrorCount% files/folders could not be copied.
CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false)
; Copies all files and folders matching SourcePattern into the folder named DestinationFolder and
; returns the number of files/folders that could not be copied.
{
; First copy all the files (but not the folders):
FileCopy, %SourcePattern%, %DestinationFolder%, %DoOverwrite%
ErrorCount := ErrorLevel
; Now copy all the folders:
Loop, %SourcePattern%, 2 ; 2 means "retrieve folders only".
{
FileCopyDir, %A_LoopFileFullPath%, %DestinationFolder%\%A_LoopFileName%, %DoOverwrite%
ErrorCount += ErrorLevel
if ErrorLevel ; Report each problem folder by name.
MsgBox Could not copy %A_LoopFileFullPath% into %DestinationFolder%.
}
return ErrorCount
}
Here is my attempt at using arrays, editing the example provided in the arrays section, which never worked:
Code:
; Write to the array:
ArrayCount = 0
Loop, Read, C:\Documents and Settings\USER\Desktop\demos\Array.txt ; This loop retrieves each line from the file, one at a time.
{
ArrayCount += 1 ; Keep track of how many items are in the array.
Array%ArrayCount% := A_LoopReadLine ; Store this line in the next array element.
}
; Read from the array:
Loop %ArrayCount%
{
; The following line uses the := operator to retrieve an array element:
element := Array%A_Index% ; A_Index is a built-in variable.
; Alternatively, you could use the "% " prefix to make MsgBox or some other command expression-capable:
MsgBox % "Element number " . A_Index . " is " . Array%A_Index%
}
*#c::FileAppend, Var := Array%A_Index% + 1, C:\Program Files\Steam\steamapps\chief_ace\counter-strike source\cstrike\record.dem, C:\Documents and Settings\USER\Desktop\demos\*.*
Could someone please lead me in the right direction? Thanks