lastknownuser Posted September 30, 2021 Posted September 30, 2021 I found some useful lisp in another forum in this topic: http://www.theswamp.org/index.php?topic=31097.0 but still I can't really figure out how to work with ZIP files. What I need is to select one ZIP file, that has folders in which there are text files that I need to access. So all that just by selecting one ZIP file with getfiled. I could extract files first, but then I would have to combine them to use getfiled command. I tried this code, written by someone in previously mentioned thread. It lists all files inside ZIP, all files in all folders. So I have file names, that are always a constant. Is there a way I could read from these certain files to get the data I want? (defun C:TESTZIPCONTENTS (/ cont filz) (setq filz (getfiled "Select a ZIP File" "" "zip" 8)) (setq cont (GetAllFilesInZip filz)) (textscr) (princ (strcat "\nContents of \"" (vl-filename-base filz) (vl-filename-extension filz) "\":\n|")) (showint cont 0) (princ) ) (defun moreinside (chkfile / cmt cnt fil its lst sbf) (if (= (vlax-get-property chkfile 'IsFolder) :vlax-true) (progn (setq sbf (vlax-get-property chkfile 'getfolder)) (setq its (vlax-invoke-method sbf 'items)) (setq cmt (vlax-get-property its 'count)) (setq cnt 0) (repeat cmt (setq fil (moreinside (vlax-invoke-method its 'item cnt))) (setq lst (cons fil lst)) (setq cnt (1+ cnt)) ) (vlax-release-object sbf) (vlax-release-object its) (gc) (cons (vla-get-name chkfile) (reverse lst)) ) (vla-get-name chkfile) ) ) (defun GetAllFilesInZip (zipFile / count file filelist files folder fso ndx path) (setq path (car (fnsplitl zipFile))) (setq fso (vlax-create-object "Shell.Application")) (setq folder (vlax-invoke fso 'NameSpace zipFile)) (setq files (vlax-invoke folder 'Items)) (setq count (vlax-get-property files 'Count)) (setq ndx 0) (repeat count (setq file (moreinside (vlax-invoke files 'Item ndx))) (setq filelist (append filelist (list file))) (setq ndx (1+ ndx)) ) (vlax-release-object folder) (vlax-release-object fso) (gc) filelist ) (defun showint (a b / str) (setq str "\n|-") (repeat b (setq str (strcat str "-"))) (foreach n a (if (listp n) (progn (princ (strcat str ">" (car n))) (showint (cdr n) (1+ b)) ) (princ (strcat str ">" n)) ) ) ) Quote
BIGAL Posted October 1, 2021 Posted October 1, 2021 You have posted elsewhere and posted about unzipping from acad to a directory. Quote
Bill Tillman Posted October 1, 2021 Posted October 1, 2021 I can see in the GetAllFilesInZip function there is a call to the shell. I haven't ever worked with LISP in this mode but do so from C# apps all the time. Once you unzip the file and then search the files for particular text or patterns. Sorry I can't be much help beyond this point. Good luck with the task. Quote
BIGAL Posted October 2, 2021 Posted October 2, 2021 Extract and read files from ZIP (theswamp.org) Quote
lastknownuser Posted October 5, 2021 Author Posted October 5, 2021 On 02/10/2021 at 09:13, BIGAL said: Extract and read files from ZIP (theswamp.org) Yes, and the same thing I'm asking here a little bit differently asked, but since then I managed to found out how to extract the files. I know the folder and files names. And now I want to know if there is a way to extract them to a temporary folder, or to delete them after I read extracted txt files. Basically by just selecting zip file to get wanted information, without having extracted files on my hard drive after using lisp Quote
mhupp Posted October 5, 2021 Posted October 5, 2021 (edited) https://www.cadtutor.net/forum/topic/64590-delete-files-directory-or-folder-on-your-computer-using-lsp/?do=findComment&comment=532121 Edited October 5, 2021 by mhupp Quote
lastknownuser Posted October 7, 2021 Author Posted October 7, 2021 On 05/10/2021 at 15:52, mhupp said: https://www.cadtutor.net/forum/topic/64590-delete-files-directory-or-folder-on-your-computer-using-lsp/?do=findComment&comment=532121 Thanks that is what I'm looking for, but its not working incorporated in my lisp, I also cannot delete the folder manually because it says the txt files inside that I'm reading from are in use. In autocad I get this: Automation Error. Description was not provided. Any way to make the files not being used anymore in lisp? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.