BIGAL Posted January 23, 2018 Share Posted January 23, 2018 I tend to clean up my junk but others dont so looking at doing it for them. we have our temp drive set to C:drive i wnat to delete all *.log *.ac$ and *.DWL etransmit etc will leave baks for now in future delete by date. The code below seesm to be only doing one delete and its not finding all the files. The code found 50 on drive 200+ ? Any ideas I was thinking of using a shell and batch file. (setq ans (vl-directory-files "C:\\acadtemp" "*.log")) (repeat (setq x (length ans)) (Princ "\n ") (princ (nth (setq x (- x 1)) ans)) (setq fname (strcat "C:\\acadtemp\\" (nth (setq x (- x 1)) ans))) (vl-file-delete fname) ) (alert "all logs deleted") Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted January 23, 2018 Share Posted January 23, 2018 You are decreasing your counter twice in every loop. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted January 23, 2018 Share Posted January 23, 2018 Maybe THIS THREAD will help. I prefer to use DOS for these tasks or even search in Windows Explorer, I believe I remember DOSLIB having something for this as well. I found an example in DOSLIB Help. Command: (dos_delete "C:\\Temp\\*.dwg") Quote Link to comment Share on other sites More sharing options...
steven-g Posted January 23, 2018 Share Posted January 23, 2018 I have most of these types of files going to a folder in my projects structure. I use the log files or at least the record of the names for keeping track of my time sheets, and so I regularly check the folder, and delete things at the end of the month, it's also a lot easier than trying to surf through the system folders in the rare event of a crash. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 23, 2018 Share Posted January 23, 2018 IMO it's easier to use foreach: (foreach x (vl-directory-files "C:\\acadtemp" "*.log") (setq fname (strcat "C:\\acadtemp\\" x)) (vl-file-delete fname) ) And if you want to delete multiple file types: (foreach ext '("*.log" "*.err" "*.bak" "*.ac$") (foreach x (vl-directory-files "C:\\acadtemp" ext) (setq fname (strcat "C:\\acadtemp\\" x)) (vl-file-delete fname) ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 24, 2018 Author Share Posted January 24, 2018 (edited) Sometimes the obvious is looking at you like the double counter. Ronjonp thanks thats what I was after. It is a bit my fault the log files are in \acadtemp\log a search of acadtemp finds thes log files in the directory below, which is not obvious. I will need to do a couple of routines to allow for different directories. Just cleaned up 200+ log files. Steven-g I use Productivity_analysis lisp for recording dwg details like time spent in dwg. Remember your on the dark side now you can run lisps. Ps have two versions shortened the report. Productivity_Analysis_Tool.lsp Edited January 24, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
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.