Results 1 to 4 of 4

Thread: strip file name

  1. #1
    Kiwi Russ Guest

    strip file name

    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

  2. #2
    Rodney Estep Guest
    (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...
    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

  3. #3
    Ken Krupa Guest
    (mapcar 'vl-filename-base mylist)

    Ken Krupa


    "Kiwi Russ" <russell@pl.net> wrote in message news:41cb6a31_2@newsprd01...
    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

  4. #4
    Rob Taylor Guest
    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

Similar Threads

  1. File, Find References, Copy Files: Truncating Long File Name
    By Devon T. Sowell in forum SolidWorks
    Replies: 8
    Last Post: 10-03-2005, 05:10 PM
  2. strip path
    By remy martin in forum SolidWorks
    Replies: 3
    Last Post: 09-23-2005, 05:10 PM
  3. Replies: 0
    Last Post: 08-22-2005, 05:10 PM
  4. Replies: 10
    Last Post: 04-07-2005, 12:35 PM
  5. importing excel file into a DGN file
    By D. Duke in forum MicroStation
    Replies: 4
    Last Post: 05-03-2004, 01:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum