list problems

Discussion in 'AutoCAD' started by Rabbit @ home, Jul 30, 2004.

  1. I've used (vl-directory-files "C:FOLDER/" "*.xyz" 1) to get a list of the
    files in "FOLDER" directory and my list returns something like: [0] 123.xyz
    [1] abc.xyz [2] mno.xyz......etc. Now, I need to strip away the extension
    ".xyz" from each of these file names, but remain in a list form. I know
    that (vl-string-right-trim ".xyz" <something>) will get rid of the
    extension, but I'm not sure how to go about using it. Any suggestion? TIA
     
    Rabbit @ home, Jul 30, 2004
    #1
  2. Rabbit @ home

    MP Guest

    (defun test()
    (mapcar
    (function(lambda (item)
    (substr item 1(-(strlen item)4))
    );l
    );f
    (list
    "test.dwg"
    "this.txt"
    "out.xls"
    )
    )
    )
     
    MP, Jul 30, 2004
    #2
  3. Rabbit @ home

    John Uhden Guest

    Maybe (mapcar 'vl-filename-base list_of_items)
     
    John Uhden, Jul 30, 2004
    #3
  4. Okay, when I added this to my routine
    <DirList is the list returned from vl-directory-list>

    (mapcar
    (function (lambda (DirList)
    (substr DirList 1(-(strlen DirList)4))
    );l
    );f
    (list
    ".xyz"
    )
    )

    It returned: ""
    --
    Rabbit @ home, down in the hole



     
    Rabbit @ home, Jul 30, 2004
    #4
  5. Maybe (mapcar 'vl-filename-base list_of_items)

    That's it! Thanks John and MP
     
    Rabbit @ home, Jul 30, 2004
    #5
  6. Rabbit @ home

    Tom Smith Guest

    You didn't apply it properly. Instead of altering the function, you should
    have simply substituted your list:

    (mapcar
    (function(lambda (item)
    (substr item 1(-(strlen item)4))))
    DirList)
     
    Tom Smith, Jul 30, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.