There is likely a bit of overhead in LEP, plus the overhead of launching processes, which is going to add up when used in a loop like that.
For this particular case, your fastest option is probably to build a C_OBJECT with the filenames as keys and the file paths as values, and in your loop you’ll just access the object. Since object key access is case-sensitive (I think?), if your file systems are case insensitive you’ll probably want to normalize case. Since C_OBJECT has some internal indexing, it should be pretty fast when used this way. A big plus would be not having to figure out separate find commands for Mac/Windows. Jim Crate > On May 16, 2017, at 4:09 PM, John Baughman via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > Are you all repeating the LEP in a loop? I am calling SysDoc_Find like this… > > vNewFolderPath:=Select folder("Select the the parent folder that contains all > documents... ";1) > ALL RECORDS([Document]) > $size:=Records in selection([Document]) > For ($i;1;$size) > GOTO SELECTED RECORD([Document];$i) > $documentToFind:=[Document]File_Name > $pathToDocumentFound:=SysDoc_Find ($documentToFind;vNewFolderPath) > > End for > > Do not know how to do a loop like this in the command line. what does it look > like? > > John > >> On May 16, 2017, at 9:45 AM, Lee Hinde via 4D_Tech <4d_tech@lists.4d.com> >> wrote: >> >> I’d second that. I just tried it in the command line on a folder with 5,144 >> (nested) files and with almost 1,400 results the response was near instant. >> >> So, I tried this in 15.4 and Mac 10.12.5. >> >> Basically stripping the convert path stuff because I was passing in the full >> path and those commands messed it up. Also, unquoted the file name. >> >> But then point is, it was instant. >> >> >> //Method: SysDoc_Find >> C_TEXT($searchFor;$1;$searchIn;$2;$pathFound;$0) >> $searchFor:=$1 >> $searchIn:=$2 >> >> //$searchIn:=Convert path system to POSIX($searchIn) >> $_txt_OSASCRIPT:="mdfind -onlyin "+$searchIn+" -name "+$searchFor >> $_t_InputStream:="" >> $_t_OutputStream:="" >> LAUNCH EXTERNAL PROCESS($_txt_OSASCRIPT;$_t_InputStream;$pathFound) >> >> //If ($pathFound#"") >> //$pathFound:=Replace string(Convert path POSIX to >> system($pathFound);"\n";””) >> >> // //Note: This is the code I ran for my tests. It is not complete as LEP >> is actually returning a list of paths to all the documents found with the >> same name. >> // //For my test I knew that there would only be one path found so I >> eliminated anything unnecessary >> // //My SysDoc_Find method actually converts pathFound to a process array, >> and returns the first element in the array. The caller can then either use >> the returned path or the array. >> // //Also, be aware that $pathFound ends with a \n. So the last element of >> the array may need to be deleted. My text to array method returns an empty >> last element. >> >> //End if >> $0:=$pathFound >> >>> On May 16, 2017, at 12:32 PM, Jeffrey Kain via 4D_Tech >>> <4d_tech@lists.4d.com> wrote: >>> >>> Which version of 4D are you using? Some versions have a bug in LEP that >>> causes them to use 100% of the CPU when they are waiting for the result, >>> thus drastically slowing everything down. >>> >>> If you repeat it from the command line instead from inside 4D, what happens? >>> >>> -- >>> Jeffrey Kain >>> jeffrey.k...@gmail.com >>> >>>> On May 16, 2017, at 3:26 PM, John Baughman via 4D_Tech >>>> <4d_tech@lists.4d.com> wrote: >>>> >>>> Interestingly this is way slower than crawling through the directories. >>>> Using my SearchFolderContents_Jut method which I posted in my original >>>> message it takes about 35 seconds to find 526 documents in a folder where >>>> the documents are at most nested 3 folders deep. Using LEP to search the >>>> same 526 documents takes almost 3 minutes! >>> >>> ********************************************************************** >>> 4D Internet Users Group (4D iNUG) >>> FAQ: http://lists.4d.com/faqnug.html >>> Archive: http://lists.4d.com/archives.html >>> Options: http://lists.4d.com/mailman/options/4d_tech >>> Unsub: mailto:4d_tech-unsubscr...@lists.4d.com >>> ********************************************************************** >> >> ********************************************************************** >> 4D Internet Users Group (4D iNUG) >> FAQ: http://lists.4d.com/faqnug.html >> Archive: http://lists.4d.com/archives.html >> Options: http://lists.4d.com/mailman/options/4d_tech >> Unsub: mailto:4d_tech-unsubscr...@lists.4d.com >> ********************************************************************** > > ********************************************************************** > 4D Internet Users Group (4D iNUG) > FAQ: http://lists.4d.com/faqnug.html > Archive: http://lists.4d.com/archives.html > Options: http://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ********************************************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************