Re: Is it possible to do a search in the file system from 4D
PERFECT! I have got to sit down and read the LRM front to back on a regular basis. I have never used DOCUMENT LIST. DOCUMENT LIST is instantaneous and works in both the windows and mac environments. Thanks Keisuke! John //quick and dirty code using DOCUMENT LIST... Message2Close vNewFolderPath:=Select folder("Select the the parent folder that contains all drawings... ";1) ARRAY TEXT($aDocList;0) DOCUMENT LIST(vNewFolderPath;$aDocList;Absolute path+Ignore invisible+Recursive parsing) ALL RECORDS([Document]) $size:=Records in selection([Document]) For ($i;1;$size) $pathFound:="" GOTO SELECTED RECORD([Document];$i) $searchFor:="@"+[Document]File_Name $found:=Find in array($aDocList;$searchFor) If ($found>0) $pathFound:=$aDocList{$found} End if End for Message2Close Keisuke Miyako via 4D_Tech <4d_tech@lists.4d.com> wrote: > DOCUMENT LIST with the "Recursive parsing" options gives you all the file > paths contained in a folder > (since v13) > > http://doc.4d.com/4Dv15/4D/15.4/DOCUMENT-LIST.301-3274226.en.html > > it has some other useful options too (Ignore invisible, Absolute path) > tha makes a lot of previous code for recursive searching pretty redundant. > > > 2017/05/16 15:59、John Baughman via 4D_Tech <4d_tech@lists.4D.com> のメール: > > > > 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. > > > > ** 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 **
Re: Is it possible to do a search in the file system from 4D
This does not work… $windowsCommand:= "dir “+[Document]File_Name+" /s” SET ENVIRONMENT VARIABLE("_4D_OPTION_CURRENT_DIRECTORY";"C:\\") SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true") LAUNCH EXTERNAL PROCESS($windowsCommand;$_t_InputStream;$pathFound) $pathFound is returned empty. It works in the command line manually. The response is quite a bit different than mdfind on the mac, but the path is there. Any suggestions would be appreciated. John > On May 16, 2017, at 11:15 AM, John Baughman via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > OK. Would something like this work… > > $windowsCommand:= "dir “+[Document]File_Name+" /s” > SET ENVIRONMENT VARIABLE("_4D_OPTION_CURRENT_DIRECTORY";"C:\\") > SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true") > LAUNCH EXTERNAL PROCESS($windowsCommand;$_t_InputStream;$pathFound) > > Am I getting close? Need to start testing in windows > > John > > >> On May 16, 2017, at 10:58 AM, John Baughmanwrote: >> >> I am rethinking what I am trying to achieve. The purpose of this exercise is >> to update file paths stored in 4D for thousands of architectural drawings >> when the folder containing all these nested drawings is moved to a different >> location locally or to a different machine. >> >> Ultimately the paths stored in 4D are sent to a web site for display in an >> end user’s browser. >> >> So currently the paths only need to be updated in 4D when the drawings >> folder is moved or reorganized. >> >> I am now thinking that maybe I should use LEP to get the current path when >> 4D gets the http request for the file, rather than relying on the path >> stored in 4D. A single call to LEP is almost instantaneous so this should >> work fine. This way I would not have to worry about where the end user puts >> or organizes the drawings as long as they are located on a drive that 4D can >> see. >> >> Ok, say I go this route, it should work great on the Mac, but what about >> windows. Is there a command similar to mdfind in the windows environment? >> >> John >> >> >> >> >>> On May 16, 2017, at 10:09 AM, John Baughman 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? > > -- >
Re: Is it possible to do a search in the file system from 4D
DOCUMENT LIST with the "Recursive parsing" options gives you all the file paths contained in a folder (since v13) http://doc.4d.com/4Dv15/4D/15.4/DOCUMENT-LIST.301-3274226.en.html it has some other useful options too (Ignore invisible, Absolute path) tha makes a lot of previous code for recursive searching pretty redundant. > 2017/05/16 15:59、John Baughman via 4D_Tech <4d_tech@lists.4D.com> のメール: > > 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. ** 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 **
Re: Is it possible to do a search in the file system from 4D
Just tested if using LEP to serve the current paths to the documents is going to work for me. It is still too slow when compared to retrieving the path directly from a field in the DB. Using LEP to get 17 paths on request from the web site takes 7-8 seconds. Passing the paths from 4D fields serves the same 17 paths in less than 1 second. The times are how long it takes a single HTTP request to get the document names and paths from 4D and display the names in a list. The list of names in some cases can be quite large. I am using 4D v16.1 on a MacBook Pro running El Capitan.If I can get LEP to work I'm am going to run the same tests on Windows. John > On May 16, 2017, at 10:58 AM, John Baughmanwrote: > > I am rethinking what I am trying to achieve. The purpose of this exercise is > to update file paths stored in 4D for thousands of architectural drawings > when the folder containing all these nested drawings is moved to a different > location locally or to a different machine. > > Ultimately the paths stored in 4D are sent to a web site for display in an > end user’s browser. > > So currently the paths only need to be updated in 4D when the drawings folder > is moved or reorganized. > > I am now thinking that maybe I should use LEP to get the current path when 4D > gets the http request for the file, rather than relying on the path stored in > 4D. A single call to LEP is almost instantaneous so this should work fine. > This way I would not have to worry about where the end user puts or organizes > the drawings as long as they are located on a drive that 4D can see. > > Ok, say I go this route, it should work great on the Mac, but what about > windows. Is there a command similar to mdfind in the windows environment? > > John > > > > >> On May 16, 2017, at 10:09 AM, John Baughman 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
Re: Is it possible to do a search in the file system from 4D
Keisuke, A great idea. I was not even aware that a file number existed. I am thinking, however, that the possibility of the number changing makes this approach a bit scary. Especially considering that a backup recovery would in fact change the file’s numbers, something I have no control over from 4D. John > On May 16, 2017, at 12:24 PM, Keisuke Miyako via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > as long as the files are moved on the same file system, > and the files are moved or edited, and not over-written (many applications do > that silently...) > then you might be able to track those files by keeping their number. > > https://github.com/miyako/4d-plugin-file > > - > > I am working on a side-project for S/MIME PGP support plugin, > and had forgotten to disable email signature replying to the list... > > > ** > 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 **
Re: Is it possible to do a search in the file system from 4D
as long as the files are moved on the same file system, and the files are moved or edited, and not over-written (many applications do that silently...) then you might be able to track those files by keeping their number. https://github.com/miyako/4d-plugin-file - I am working on a side-project for S/MIME PGP support plugin, and had forgotten to disable email signature replying to the list... ** 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 **
Re: Is it possible to do a search in the file system from 4D
Keisuke, For some reason I am getting posts to the NUG from you without content… > On May 16, 2017, at 12:03 PM, Keisuke Miyako via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > This message contains a digitally signed email which can be read by opening > the attachment. Got 2 so far. JOhn ** 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 **
Re: Is it possible to do a search in the file system from 4D
This message contains a digitally signed email which can be read by opening the attachment. ** 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 **
Re: Is it possible to do a search in the file system from 4D
OK. Would something like this work… $windowsCommand:= "dir “+[Document]File_Name+" /s” SET ENVIRONMENT VARIABLE("_4D_OPTION_CURRENT_DIRECTORY";"C:\\") SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true") LAUNCH EXTERNAL PROCESS($windowsCommand;$_t_InputStream;$pathFound) Am I getting close? Need to start testing in windows John > On May 16, 2017, at 10:58 AM, John Baughmanwrote: > > I am rethinking what I am trying to achieve. The purpose of this exercise is > to update file paths stored in 4D for thousands of architectural drawings > when the folder containing all these nested drawings is moved to a different > location locally or to a different machine. > > Ultimately the paths stored in 4D are sent to a web site for display in an > end user’s browser. > > So currently the paths only need to be updated in 4D when the drawings folder > is moved or reorganized. > > I am now thinking that maybe I should use LEP to get the current path when 4D > gets the http request for the file, rather than relying on the path stored in > 4D. A single call to LEP is almost instantaneous so this should work fine. > This way I would not have to worry about where the end user puts or organizes > the drawings as long as they are located on a drive that 4D can see. > > Ok, say I go this route, it should work great on the Mac, but what about > windows. Is there a command similar to mdfind in the windows environment? > > John > > > > >> On May 16, 2017, at 10:09 AM, John Baughman 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
Re: Is it possible to do a search in the file system from 4D
I am rethinking what I am trying to achieve. The purpose of this exercise is to update file paths stored in 4D for thousands of architectural drawings when the folder containing all these nested drawings is moved to a different location locally or to a different machine. Ultimately the paths stored in 4D are sent to a web site for display in an end user’s browser. So currently the paths only need to be updated in 4D when the drawings folder is moved or reorganized. I am now thinking that maybe I should use LEP to get the current path when 4D gets the http request for the file, rather than relying on the path stored in 4D. A single call to LEP is almost instantaneous so this should work fine. This way I would not have to worry about where the end user puts or organizes the drawings as long as they are located on a drive that 4D can see. Ok, say I go this route, it should work great on the Mac, but what about windows. Is there a command similar to mdfind in the windows environment? John > On May 16, 2017, at 10:09 AM, John Baughmanwrote: > > 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 >>
Re: Is it possible to do a search in the file system from 4D
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 >
Re: Is it possible to do a search in the file system from 4D
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 **
Re: Is it possible to do a search in the file system from 4D
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 **
Re: Is it possible to do a search in the file system from 4D
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 **
Re: Is it possible to do a search in the file system from 4D
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 **
Re: Is it possible to do a search in the file system from 4D
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 **
Is it possible to do a search in the file system from 4D
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 **