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

How to? How can I use select with a folder that already contains parentheses?

Discussion in 'Support' started by gschizas, Dec 7, 2013.

  1. gschizas

    Joined:
    May 30, 2008
    Messages:
    81
    Likes Received:
    0
    Let's say for example that I have this command:

    Code:
    for /a:d %i in ("C:\Program Files (x86)\*") do echo %i
    This works properly, as it should

    Now I want to use the same command, only under a select command:

    Code:
    select ("C:\Program Files (x86)\*") do echo %i
    Unfortunately, I get the error:
    Code:
    TCC: (Sys) The system cannot find the file specified.
     "C:\Program Files (x86"
    Ok, so I'll try escaping the closing parenthesis:
    Code:
    C:\Users\GSchizas>select ("C:\Program Files (x86^)\*") do echo %i
    No luck:
    Code:
    TCC: (Sys) The system cannot find the file specified.
     "C:\Program Files (x86^)\*"
    Maybe escaping both?

    Code:
    C:\Users\GSchizas>select ("C:\Program Files ^(x86^)\*") do echo %i
    Nope.

    Code:
    TCC: (Sys) The system cannot find the file specified.
     "C:\Program Files ^(x86^)\*"
    Is there a way to do what I need?

    (BTW, I'm not really trying to echo the contents of "C:\Program Files (x86)" - I'm trying to copy some files from a directory with parentheses in its name)
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,358
    Likes Received:
    39
    Okay, this isn't a good solution, but there's always SUBST....
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,076
    Likes Received:
    30
    1. You're using SELECT wrong. It's "SELECT command ( files )".
    2. This works (and I have no idea why)!
    Code:
    v:\> select echo ( "%@lfn["v:\Program Files (x86)"]\*" )
    "V:\Program Files (x86)\foo.txt"
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,076
    Likes Received:
    30
    Again, a little more clearly:
    Code:
    v:\> select del ( "%@lfn["v:\Program Files (x86)"]\*" )
    Deleting V:\Program Files (x86)\foo.txt
      1 file deleted
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,076
    Likes Received:
    30
    A tad more work, and a bit more elegant ...
    Code:
    v:\> set files="v:\Program Files (x86)\*"
    
    v:\> select del ( %files )
    Deleting V:\Program Files (x86)\foo.txt
      1 file deleted
    I think Win64 has the "ProgramFiles(x86)" variable. But unfortunately, specifying "%ProgramFiles(x86)\*" won't work for the same reason the original attempt failed, because SELECT isn't very smart when it comes to handling parentheses on its command line.

    If the command you're going to apply to the selected files accepts multiple filenames (see help for SELECT) on its command line (as DEL does) and you want them all processed by a single command, you can avoid the parentheses-confusion by using square brackets.
    Code:
    v:\> select echo [ "v:\Program Files (x86)\*" ]
    "v:\Program Files (x86)\foo.txt" "v:\Program Files (x86)\foo1.txt"
     
  6. MickeyF

    Joined:
    Jun 3, 2008
    Messages:
    76
    Likes Received:
    1
    My problem is related to this thread, so I thought I would add it to here. I want to use the SELECT command, but to execute a program in the Program Files (x86) folder, and using the selection part to choose which file for the program to open.

    What I tried was:

    select "c:\Program Files (x86)\InstallShield\DemoShield\7.5\Program\Designer.exe" %@quote[(*.dbd)]

    No good. The parentheses for x86 got in the way. I also tried:


    select "c:\Program Files (x86)\InstallShield\DemoShield\7.5\Program\Designer.exe" %@quote[[*.dbd]]

    This failed the same way.

    Short of using a SUBST or some other really ugly kludge to find a way to refer to the x86 folder, how is this done?
     
  7. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,043
    Likes Received:
    0
    set CmdToRun=c:\Program Files (x86)\InstallShield\DemoShield\7.5\Program\Designer.exe
    select "%CmdToRun" (*.dbd)
     
  8. MickeyF

    Joined:
    Jun 3, 2008
    Messages:
    76
    Likes Received:
    1
    Thanks, Charles. I would have thought I would need %@quote[] around the (*.dbd) part, since some of my filenames have spaces in them, but apparently the select command handles this automatically.

    And I appreciate the timely support I always get from JPSoft. Thanks!
     
    Charles G likes this.

Share This Page