Jump to content

Recommended Posts

Posted

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")

Posted

You are decreasing your counter twice in every loop.

Posted

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")

Posted

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.

Posted

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)
 )
)

Posted (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 by BIGAL

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...