Jump to content

File Saveas Lisp


Steven P

Recommended Posts

Good morning,

I am asking on the chance that someone has done this.

 

I am wanting to saveas a file, adding a suffix or prefix to the file name

So Drawing.dwg becomes Drawing_Old.Dwg for example

 

However Drawing_Old.Dwg might exist, does anyone have a routine that will add a (1) (or the next highest number) to the new file name

So Drawing.dwg might become Prefix_Drawing_Old(5).dwg

 

 

 

(I'm thinking some thing along the lines of this (yeah, I know it needs proper syntax and stuff, just my quick thoughts):

 

Setq drawing (findfile Prefix_Drawing_Old.dwg)
If (= nil drawing saveas Prefix_Drawing_Old.dwg)
If (/= nil drawing
Progn
setq x 1
(while (/= drawing nil)
findfile Prefix_Drawing_Old(x).dwg
setq x (+ 1 x)
);end while
saveas Prefix_Drawing_Old(x)
))f

Link to comment
Share on other sites

You may be better using if I can remember or find it you can get a list of drawing_name*.dwg so sort list and look at last entry is it not 1 or is it last number. It may have used a doslib function. Will try to find. Maybe check Lee-mac.com.

Link to comment
Share on other sites

Thanks Al, I wouldn't have thought of that, that would be a lot neater I think

 

 

 

Lee-Mac.com.. schoolboy error not to check there first, whoops. Guess where google is taking me next?

Link to comment
Share on other sites

I am wanting to saveas a file, adding a suffix or prefix to the file name

So Drawing.dwg becomes Drawing_Old.Dwg for example

 

However Drawing_Old.Dwg might exist, does anyone have a routine that will add a (1) (or the next highest number) to the new file name

So Drawing.dwg might become Prefix_Drawing_Old(5).dwg

 

You may refer to my LM:uniquefilename function posted here.

Link to comment
Share on other sites

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