Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

if not exist create new txt file in ......

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
The_Caddie
397 Views, 2 Replies

if not exist create new txt file in ......

Hi,

 

I'm ussing the following to create a dirctory ussing lisp;

 

;CREATING NESSESARY DIRECTORYS...
(vl-mkdir "C:\\ICT")
(vl-mkdir "C:\\ICT\\AutoCAD_Architecture_suit_2012")
(vl-mkdir "C:\\ICT\\AutoCAD_Architecture_suit_2012\\CUSTOM")
(vl-mkdir "C:\\ICT\\AutoCAD_Architecture_suit_2012\\CUSTOM\\WOOD Clones")
(vl-mkdir "C:\\ICT\\AutoCAD_Architecture_suit_2012\\CUSTOM\\WOOD Clones\\PEN")

 works nice, but now I want to create an empty fresh txt file in that last directory, this is proving beyond my knowlege even more tricky only if it already dosnt exist.

 

dose any body know how to acomplish either or both?

Tags (1)
2 REPLIES 2
Message 2 of 3
M_Hensley
in reply to: The_Caddie

One way to do it would be to open a file for writing then write a carriage return and close it. (This will create a new file or overwrite any file by the same name that may already exist.)

 

(setq f1 (open "C:\\ICT\\AutoCAD_Architecture_suit_2012\\CUSTOM\\​WOOD Clones\\PEN\\myfile.txt" "w"))

(princ "\n" f1)

(close f1)

 

Message 3 of 3
pbejse
in reply to: The_Caddie


@The_Caddie wrote:

Hi,

 

I'm ussing the following to create a dirctory ussing lisp;

 

;CREATING NESSESARY DIRECTORYS...
(vl-mkdir "C:\\ICT")
(vl-mkdir "C:\\ICT\\AutoCAD_Architecture_suit_2012")
(vl-mkdir "C:\\ICT\\AutoCAD_Architecture_suit_2012\\CUSTOM")
(vl-mkdir "C:\\ICT\\AutoCAD_Architecture_suit_2012\\CUSTOM\\WOOD Clones")
(vl-mkdir "C:\\ICT\\AutoCAD_Architecture_suit_2012\\CUSTOM\\WOOD Clones\\PEN")

 works nice, but now I want to create an empty fresh txt file in that last directory, this is proving beyond my knowlege even more tricky only if it already dosnt exist.

 

dose any body know how to acomplish either or both?


(findfile "using your newly created folder for path and filenmae of text to be created")

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost