strip file name
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
strip file name

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
Kiwi Russ
Guest





Posted: Fri Dec 24, 2004 6:00 am    Post subject: strip file name Reply with quote

If I have a list such as :

("myfile1.dwg" "myfile2.dwg" "myfile3.dwg" etc .....)

how would I strip the .dwg from all the elements, so that the list would
look something like:

("myfile1" "myfile2" "myfile3" etc .....)

thanks Russ

Back to top
Rodney Estep
Guest





Posted: Fri Dec 24, 2004 6:43 am    Post subject: Re: strip file name Reply with quote

(foreach n mylist (setq newlist (append newlist (substr n 1 (- (strlen n)
4)))))
(setq mylist newlist newlist nil)


Did not test but this is how to do it assuming of course that length of the
extension is the same.
Another approach that would work is stepping thru each letter of the string
until you find the period then crop it off there.




Rodney
"Kiwi Russ" <russell@pl.net> wrote in message news:41cb6a31_2@newsprd01...
Quote:
If I have a list such as :

("myfile1.dwg" "myfile2.dwg" "myfile3.dwg" etc .....)

how would I strip the .dwg from all the elements, so that the list would
look something like:

("myfile1" "myfile2" "myfile3" etc .....)

thanks Russ
Back to top
Ken Krupa
Guest





Posted: Fri Dec 24, 2004 6:43 am    Post subject: Re: strip file name Reply with quote

(mapcar 'vl-filename-base mylist)

Ken Krupa


"Kiwi Russ" <russell@pl.net> wrote in message news:41cb6a31_2@newsprd01...
Quote:
If I have a list such as :

("myfile1.dwg" "myfile2.dwg" "myfile3.dwg" etc .....)

how would I strip the .dwg from all the elements, so that the list would
look something like:

("myfile1" "myfile2" "myfile3" etc .....)

thanks Russ


Back to top
Rob Taylor
Guest





Posted: Fri Dec 24, 2004 7:48 am    Post subject: Re: strip file name Reply with quote

Russ

Ken Krupa reply
(mapcar 'vl-filename-base mylist) is a good one

it also works for all file types
(setq MyList '("myfile1.lsp" "myfile2.lsp" "myfile3.lsp" "myfile42.lsp"))
(mapcar 'vl-filename-base MyList)

result :
("myfile1" "myfile2" "myfile3" "myfile42")

so it's can replace some code in that MakefasM routine!
Damn it, I'm going to have to learn more visual lisp!!

Cheers
Rob
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB