HI
Sorry if I'm being dense here, I've searched the forums and looked at the help pages and am struggling to work this out.
The scenario: I have a list of files in a folder which I want to individually open, perform an action, then close again. My working code is:
FileSelectFolder, MyFolder ; Ask the user to pick a folder.
msgbox, %MyFolder%
Run, "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" "%MyFolder%\blank.pdf"
What I can't work out is how to loop the file names into a variable so instead of "%MyFolder%\blank.pdf" but I require "%MyFolder%\%MyFile% with each iteration of the loop amending the MyFile variable to the next file name in the folder
I am only just beginning to use AHK so any guidance would be greatly appreciated
Loop files in specified folder and perform action on individual files Topic is solved
Re: Loop files in specified folder and perform action on individual files
Ok so I think I have now realised I don't need to assign the file name to a variable because the File-Loop will automatically do this for me: I have now amended my code to read:
FileSelectFolder, MyFolder ; Ask the user to pick a folder.
msgbox, %MyFolder%
Loop, Files, %MyFolder%
{
msgbox, %A_LoopFileFullPath%
;The below line works to open Adobe DC
Run, "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" "%MyFolder%\%A_LoopFileName%"
FileSelectFolder, MyFolder ; Ask the user to pick a folder.
msgbox, %MyFolder%
Loop, Files, %MyFolder%
{
msgbox, %A_LoopFileFullPath%
;The below line works to open Adobe DC
Run, "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" "%MyFolder%\%A_LoopFileName%"
Re: Loop files in specified folder and perform action on individual files Topic is solved
Code: Select all
FileSelectFolder, MyFolder ; Ask the user to pick a folder.
Location := MyFolder "\*.pdf" ; loop thought pdf only
Loop, files, %Location%, R
Run, %A_LoopFileFullPath%
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: Loop files in specified folder and perform action on individual files
Thanks Xeo,
I realised I was running an old version AHK and the syntax I was using from the help guide was for a more recent version. I have amended to the older versions syntax and is now working like a treat
I realised I was running an old version AHK and the syntax I was using from the help guide was for a more recent version. I have amended to the older versions syntax and is now working like a treat
Who is online
Users browsing this forum: Google [Bot] and 230 guests