Request for custom lisp routine rename txt

Request for custom lisp routine rename txt

Hans_Knol
Advocate Advocate
763 Views
1 Reply
Message 1 of 2

Request for custom lisp routine rename txt

Hans_Knol
Advocate
Advocate

I'm hoping to get some help to come up with a custom  lisp routine that changes the name of an exported report. The reports are exported using AutoCAD Electrical and must get the name of the active drawing, it's not possible to give them the right names directly. The location of the report is always the same, "C:\Data\AppData\Export\" the name of the report what is exported before renaming will be "Wirelist1.txt" 

Hans Knol
0 Likes
Accepted solutions (1)
764 Views
1 Reply
Reply (1)
Message 2 of 2

CodeDing
Advisor
Advisor
Accepted solution

@Hans_Knol ,

 

Pretty straight forward. Is this what you're looking to accomplish?

(defun c:FIRE ( / dName tmp)
;FIle REname
(vl-load-com)
(setq dName (substr (getvar 'DWGNAME) 1 (- (strlen (getvar 'DWGNAME)) 4)))
(if (vl-file-rename "C:/Data/AppData/Export/Wirelist1.txt" (strcat "C:/Data/AppData/Export/" dName ".txt"))
  (progn (setq tmp "\nFile successfully renamed.") (prompt tmp) (alert tmp))
  (progn (setq tmp "\nFile rename was unsuccessful...") (prompt tmp) (alert tmp))
);if
(princ)
);defun

Best,

~DD

0 Likes