Thanks Nigel, Your suggestion works. So I wrote a quick method to test using the following…
$_txt_OSASCRIPT:="mdfind -onlyin "+$searchIn+" -name \""+$searchFor+"\”" 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! I have pasted my LEP test method below. Any thoughts? John —————— //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 1:39 AM, Nigel Greenlee via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > Hi > > On OSX this is easy to do-something like this should work > > $_t_DocumentPath:=<—known name //if a partialthe image path is know > $_txt_OSASCRIPT:="mdfind "+Char(34)+$_t_DocumentPath+Char(34) > $_t_InputStream:="" > $_t_OutputStream:="" > LAUNCH EXTERNAL PROCESS($_txt_OSASCRIPT;$_t_InputStream;$_t_OutputStream) > > > > >> On 16 May 2017, at 07:59, John Baughman via 4D_Tech <4d_tech@lists.4d.com> >> wrote: >> >> I am thinking that perhaps using Launch External Process there might be a >> way to search for a file and get back the path to the file if found. >> >> I have a method that recursively crawls through a volume or folder to locate >> a file, but it is relatively slow. It is pasted below. Any ideas to make >> this more efficient or know how to use LEP to do a file search. Needs to >> work on both Mac and Windows. >> >> Thanks, >> >> John >> >> //Method: SearchFolderContents_Jut >> C_TEXT($1;$folderPath;$2;$documentToFind;$0;$pathToDocumentFound) >> $folderPath:=$1 >> $documentToFind:=$2 >> $pathToDocumentFound:="" >> >> DOCUMENT LIST($folderPath;$aDocuments) >> $found:=Count in array($aDocuments;$documentToFind) >> >> If ($found>0) >> $pathToDocumentFound:=$folderPath+$documentToFind >> >> End if >> >> If ($pathToDocumentFound="") >> FOLDER LIST($folderPath;$aFolders) >> >> For ($i;1;Size of array($aFolders)) >> $pathToDocumentFound:=SearchFolderContents_Jut >> ($folderPath+$aFolders{$i}+Folder separator;$documentToFind) >> If ($pathToDocumentFound#"") >> $i:=Size of array($aFolders)+10 >> >> End if >> >> End for >> >> End if >> >> $0:=$pathToDocumentFound >> ********************************************************************** >> 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 **********************************************************************