1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DO f in /L <list of file names>?

Discussion in 'Support' started by vefatica, Aug 22, 2012.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    I want to ...
    Code:
    alias foo `do f in /L %$ (...)`
    where the arguments to the alias will be file names (quoted if necessary). DO's handling of a list (/L) seems to prevent this.
    Code:
    v:\> do f in /L "1 2" 3 4 ( echo %f )
    "1
    2"
    3
    4
    FOR %f IN ( %$ ) handles it OK. And I suppose I could use a delimiter (say ';') but then I'd have to talk myself out of the 20+ year habit of separating file names with spaces. Is there a reason why quoted strings among DO /L's set are not handled as they are everywhere else in TCC?
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    DO /L cannot handle filenames; as the docs say it is for strings (which have no concept of quoted args or LFNs), not "lists" or a "set" (whatever you mean by that).

    If you want to pass filenames, you don't need (or want) a /L.
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    But without /L, you can't give it a space-separated list of file names ( like an alias's %$ ) ... or can you?
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    Sure you can.
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    But a file must (1) exist and (2) be in the current (or specified) directory to be processed. I want to specify any collection of filenames and have those that don't exist be created. Can I get the same result as this alias with DO?
    Code:
    v:\> alias e
    for %f in ( %$ ) if not exist %f touch /q /c %f & textpad %$
    Below, both files exist by the time the editor is started.
    Code:
    v:\> e "v:\1 2.txt" "v:\test\3 4.txt"
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    DO expects filenames to exist; it doesn't process imaginary names.

    If you're determined to do it in DO (and I don't know why you would be), you'll have to use an @file list.
     
  7. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    DO /L's handling of quoted spaces does seem surprising and awkward. Doubtless you can't change it without breaking eleven hundred batch files. How about a new option, say /W, that does the same job, but recognizes quoted args the way almost everything else does?
     

Share This Page