TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Vikram on March 12, 2020, 01:57:43 AM
-
I have made this lisp to delete a file but its not working. Path is correct I checked executing same path. But I also tried using the command "DEL" in cmd to delete the file from that folder and it gives error "System cannot find path specified" I tried using cmd in admin mode but no success.
Command: "DEl C:\\Log_Files\\ABC.mtn"
(the text file is in .mtn extension)
Interesting thing is it deletes the file which are on Desktop
(defun c:DSTDEL ( / fnam )
(setq fnam (strcat "C:\\Log_Files\\"(vl-filename-base (getvar "dwgname")) ".mtn"))
(setq cmd (strcat "DEL " fnam))
(command "SHELL" cmd)
(princ)
)
-
Use vl-file-delete function:
-
Thanks for suggestion!
Though I found out the problem.
My path was something like this C:\CAD Files\Log_Files\ABC.txt
cmd was not able to find files where there is space between folder names for example here its CAD Files. I renamed that folder to CAD-Files and my lisp worked fine
-
Double quoting the path is the solution many others have applied when using shell commands.
-
(defun C:YJKP() (ALERT "Please leave as soon as you are under 18" )
(setq A1 "http://v.qq.com/x/cover/2iqrhqekbtgwp1s.html")
(command "browser" A1 )
(PRINC)
)
-
(vl-file-delete filename)
-
try this :
(acet-file-remove filename)