vl-directory-files limits

vl-directory-files limits

SAPER59
Advocate Advocate
1,621 Views
18 Replies
Message 1 of 19

vl-directory-files limits

SAPER59
Advocate
Advocate

I'm using vl-directory-files to get and modiy all files inside a directory but has a limit aroun 988 files, the others are not included in the list obtained

Is it there a limit for the ammount of files, and in that case how to solve this?

Thanks

0 Likes
Accepted solutions (1)
1,622 Views
18 Replies
Replies (18)
Message 2 of 19

hak_vz
Advisor
Advisor

Haven't had a situation to work with so many files in a directory, and I'm not aware of the limit.

 All your files in a directory are of same type?

If not try to search for files by type or use DOS like match patterns, and then join the resulting lists.

Let say fires search for .dwg files, than .txt.

 

(vl-directory-files "c:\\myfiles\\" "*.dwg")

(vl-directory-files "c:\\myfiles\\" "*.txt")

 

If they are of the same type try to use search pattern mask

(vl-directory-files "c:\\myfiles\\" "A*.dwg")

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 19

pbejse
Mentor
Mentor

@SAPER59 wrote:

I'm using vl-directory-files to get and modiy all files inside a directory but has a limit aroun 988 files, 


 

This thing beats the function by 11

pbejse_0-1602681245389.png

The maximum score is 999

 

 

Message 4 of 19

cadffm
Consultant
Consultant

@SAPER59 

I don't know what your exact vl-directory-files statement is,

and i don't know about limits,

but the limit is not 998.

Quick test on my HD: Without a problem 1030 DWG in a directory

I used (length(setq DL (vl-directory-files "C:\\MyPath" "*.*" 1)))

 

Are you sure the problem is vl-directory-files?

Sebastian

0 Likes
Message 5 of 19

hak_vz
Advisor
Advisor

When you create large list with 1000 + elements and try to list it in a console it will not  show, but list is created and it can be shown and used. For a test one can save it to the output file.

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 6 of 19

ronjonp
Advisor
Advisor

Over 12k here:

ronjonp_0-1602691758215.png

 

0 Likes
Message 7 of 19

cadffm
Consultant
Consultant

@hak_vz wrote:

When you create large list with 1000 + elements and try to list it in a console it will not  show, but list is created and it can be shown and used. For a test one can save it to the output file.

 


I am missing the question you answered to, but:

That's not right, or i don't understand what you trying to say.

It is depending of your function & commands

 

(foreach ... (princ...)) works for example

 

Sebastian

0 Likes
Message 8 of 19

hak_vz
Advisor
Advisor
Accepted solution

@SAPER59 

 

Try this code that uses Windows Scripting Shell.

 

(defun c:getFilesInDirectory nil 
    (getFilesInDirectory (getstring "\nEnter directory path string >"))
)

(defun getFilesInDirectory (path / wshShell allFiles stream filelist str_to_lst)
(defun str_to_lst (str del / len lst pos )
    (setq len (1+ (strlen del)))
    (while (setq pos (vl-string-search del str))
        (setq lst (cons (substr str 1 pos) lst)
              str (substr str (+ pos len))
        )
    )
    (reverse (cons str lst))
)
(setq wshShell (vlax-create-object "WScript.Shell"))
(setq allFiles (vlax-invoke-method wshShell 'Exec (strcat"cmd /c dir " path " /a:-d /b")))
(setq stream (vlax-get-property allFiles 'StdOut))
(setq filelist (vlax-invoke-method stream 'ReadAll))
(str_to_lst filelist "\r\n")
)

Usage :

(getFilesInDirectory "H:\\Lisp\\*.lsp")

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 9 of 19

hak_vz
Advisor
Advisor

@cadffm  When you create really large list and if you use ! in system console it won't show i.e it wont be listed.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 10 of 19

ronjonp
Advisor
Advisor

There is also this if you want to process subdirectories as well.

0 Likes
Message 11 of 19

pbejse
Mentor
Mentor

@SAPER59 wrote:

I'm using vl-directory-files to get and modiy all files inside a directory but has a limit aroun 988 files, the others are not included in the list obtained


The question everyone is asking is what limit?  number of items on a list? 

Items you can "see" on vlide console?

Most likely there is a bug in your code.

 

I remember one time:

A code encountered a temporary file and stops, the file inm question's description is just "File" and 0KB not any defined file nor a folder.  

 

I included this check.

 

(vl-filename-extension thefile)

 

Eveything went smoothly after that.

 

 

Message 12 of 19

cadffm
Consultant
Consultant

@hak_vz wrote:

@cadffm  When you create really large list and if you use ! in system console it won't show i.e it wont be listed.


Perhaps, but not  a limit of 998 or...

 

>"Try this code that uses Windows Scripting Shell."

Sorry. No time and no desire, Nothing to do with the topic & question, so it's offtopic

 

As i wrote: It is depending of your function & commands

thx

 

Sebastian

0 Likes
Message 13 of 19

hak_vz
Advisor
Advisor

@cadffm 


@cadffm wrote:

@hak_vz wrote:

@cadffm  When you create really large list and if you use ! in system console it won't show i.e it wont be listed.


Perhaps, but not  a limit of 998 or...

 

>"Try this code that uses Windows Scripting Shell."

Sorry. No time and no desire, Nothing to do with the topic & question, so it's off topic


Sorry @cadffm  but I don't agree that it is off topic.

Let @SAPER59  test the code and see if list length received with both method is equal. There have been posts in the pasts that complain about vla-directory-files method and limits. If he uses some older version of Acad or derivative anything is possible.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 14 of 19

cadffm
Consultant
Consultant

@hak_vz 

Yes, okay
Instead of first determining if there is a problem, you can just take another route instead.

(I mistakenly assumed earlier that you posted the code for me, which is not the case, that was the reason why I had even replied to it)

I favor checking first
whether there is a problem
what the problem is
and subsequently
I'm trying to solve the problem if it doesn't work
then I go another way:

Advantage: You expand your knowledge and thus know your way around better.

And in the case of a forum question, I also try to answer the question asked first.

The alternate code wasn't totally off-topic, but doesn't answer the question.

Kudo4u
Sebastian

Sebastian

0 Likes
Message 15 of 19

Sea-Haven
Mentor
Mentor

Using old fashioned DOS you can get a list of files into say a text file. This can be ran as a Shell function in lisp.

 

DIR c:\topleveldirectory\*.dwg /b /s >dwgs.txt

0 Likes
Message 16 of 19

pbejse
Mentor
Mentor

That did not tell us anything on why it max out on 988. 🤔 

We never did know why it behaved that way on OP's end. Not a proper way to end a discussion IMO, Oh well.

 

 

Message 17 of 19

ronjonp
Advisor
Advisor

@pbejse wrote:

That did not tell us anything on why it max out on 988. 🤔 

We never did know why it behaved that way on OP's end. Not a proper way to end a discussion IMO, Oh well.

 

 


@pbejse  Agreed. 🍻

0 Likes
Message 18 of 19

john.uhden
Mentor
Mentor

I disagree.  The OP obviously wants to get a list of all the files in a directory.  If he has experienced mistrust with vl-directory files, then he might get more comfortable with an alternate method.  I remember a time when (vla-whatever object) did not work but (vlax-invoke object 'whatever) or (vlax-invoke-method object 'whatever) would, or vice versa.  I really didn't care why.  I just wanted something that worked.  But that's only an opinion.

John F. Uhden

0 Likes
Message 19 of 19

ronjonp
Advisor
Advisor

@john.uhden wrote:

I disagree.  The OP obviously wants to get a list of all the files in a directory.  If he has experienced mistrust with vl-directory files, then he might get more comfortable with an alternate method.  I remember a time when (vla-whatever object) did not work but (vlax-invoke object 'whatever) or (vlax-invoke-method object 'whatever) would, or vice versa.  I really didn't care why.  I just wanted something that worked.  But that's only an opinion.


I'd still like a data set to see where this 'limit' is reached. I have never had a problem with it in the past 20 years.

0 Likes