Loop, "C:\My Docs\*.jpg" "C:\My pics\*.jpg" "D:\New\*.ahk",1, 1 { --------- }

Loop, Files and Folders
Started by
sosaited
, Nov 18 2005 07:39 PM
5 replies to this topic
It would be useful if File and Folder Loop would accpet MULTIPLE PATTERNS :
#1
-
Posted 18 November 2005 - 07:39 PM

My small "thanks" to AHK in shape of these dedicated 3d images

Maybe the following construct will suffice until this wish is granted:
pattern = c:\program files\*.ahk|*.jpg loop, Parse, pattern, | loop, %A_LoopField%, 1, 1 found = %found%`n%A_LoopFileFullPath% MsgBox, %found%
#2
-
Posted 18 November 2005 - 10:28 PM

I think you meant something like this :?:
by the way, this method takes very long (compared to the Wish i posted) if the "Operations" in the both Loops are same. i.e if only one Loop is running (working on BOTH jpg, ahk) each command in it will act on both type of files, thus saving time
Thanks
pattern = C:\docs\*.jpg|C:\docs\*.ahk Loop, Parse, pattern, | { Loop, %A_LoopField%,1, 1 { ...... } }
by the way, this method takes very long (compared to the Wish i posted) if the "Operations" in the both Loops are same. i.e if only one Loop is running (working on BOTH jpg, ahk) each command in it will act on both type of files, thus saving time
Thanks
#3
-
Posted 19 November 2005 - 07:55 PM

My small "thanks" to AHK in shape of these dedicated 3d images

I think you meant something like this :?:
No. What I posted is correct. You would of course need to adjust the details to suit your needs.
by the way, this method takes very long (compared to the Wish i posted) if the "Operations" in the both Loops are same. i.e if only one Loop is running (working on BOTH jpg, ahk) each command in it will act on both type of files, thus saving time
How is that? For each iteration of the loop, only one file will be acted upon. The result will be the same for the one loop or two loop method. Also, there is only one active loop in the two loop method. The outer loop acts as a server for the inner loop, where various operations (i.e., activities) will occur.
Any significant performance differential can be accounted for in the outer parsing loop, which should be minimal.
In any case, the suggested construct is designed to be a temporary [purely AHk] solution. Although, the non-script solution will be similar.
#4
-
Posted 19 November 2005 - 11:08 PM

I don't see the difference between the 2 scripts above, except the braces, which some prefer to add (who is paid by the number of lines of code he writes). But there can be a factor of 2 slow down with the double loop method. If the directory is huge, and only a few entries are processed, scanning the files consumes most of the running time. And if you have many patterns, like *.jpg, *.jpeg, *.gif, *.tif, *.tiff ... this slowdown can be significant. There are over a hundred different picture file extensions, so finding the pictures can take 100 times longer than necessary.
The other loop order is not better, either, when we find all the files and check if their extensions are in a list. In this case the slow interpreted script has to touch each file, instead of the faster internal search. This wish can really speed up things.
The other loop order is not better, either, when we find all the files and check if their extensions are in a list. In this case the slow interpreted script has to touch each file, instead of the faster internal search. This wish can really speed up things.
#5
-
Posted 20 November 2005 - 12:29 AM

You can Loop through your Files with *.*, get the Fileextension, compare it to your Whitelist and then do your command.
#6
-
Posted 11 November 2015 - 06:37 AM
