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

May 30, 2008
80
0
Gerakas, Greece
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)
 
May 20, 2008
11,437
99
Syracuse, NY, USA
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"
 
May 20, 2008
11,437
99
Syracuse, NY, USA
Again, a little more clearly:
Code:
v:\> select del ( "%@lfn["v:\Program Files (x86)"]\*" )
Deleting V:\Program Files (x86)\foo.txt
  1 file deleted
 
May 20, 2008
11,437
99
Syracuse, NY, USA
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"
 
Jun 3, 2008
130
3
Temecula, CA
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?
 
Apr 2, 2011
1,442
10
54
North Carolina, USA
set CmdToRun=c:\Program Files (x86)\InstallShield\DemoShield\7.5\Program\Designer.exe
select "%CmdToRun" (*.dbd)
 
Jun 3, 2008
130
3
Temecula, CA
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!
 
  • Like
Reactions: Charles G
Similar threads
Thread starter Title Forum Replies Date
R @select inside alias gives different (insanely small) window Support 7
Joe Caverly Windows Terminal and @SELECT Support 13
WinLanEm @SELECT problem Support 6
T @select and @selectarray issues Support 2
C How to? Select 100 random pictures from 30,000 Support 8
MikeBaas How to? SELECT: exclude files / display prompt Support 2
rps Documentation "Select" command switch order incorrect Support 4
mikea How to? @select[] window size, redux. Support 3
vefatica IDE double-click select? Support 29
T How to? Select and Delete text Support 6
mikea How to? Understanding @select[] Support 2
vhodro How to? Select text Support 10
WavSlave Fixed Escaping out of SELECT sometimes still executes the command Support 2
B Select and run lines from Command Input panel? Support 1
nikbackm Fixed v15: Issue with @select Support 3
G Fixed v15.00.27: @SELECT Support 10
D ini directives and @select example in Help Support 0
ehab aboudaya How to? Copy to clipboard on select Support 5
Phileosophos SELECT command opens additional tab Support 9
S SELECT DEL (*D.DLL) - output curious Support 8
vefatica Positioning @SELECT[] popup? Support 3
WadeHatler Any way to restore the Text Based "Select File" Windows in TCC Support 2
Stefano Piccardi how to @SELECT redirected input? Support 4
Joe Caverly Error when sorting list alphabetically for @select Support 2
S SELECT - does it support ranges? Support 2
nikbackm @select function and TAB characters Support 1
Joe Caverly @select like 4DOS Support 1
D Can you feed a file list to SELECT? Support 1
A @select versio 10.31 Support 1
nikbackm @select window problem Support 12
fishman@panix.com Startup Folder? Support 3
C writing folder names with JPSoft special chars like &...... Support 4
R How to? Set default application in a special folder Support 4
R How to? Open Take Command at current folder Support 7
D How to? Pass OpenHere Folder to CMD? Support 6
Chen Touboul When i try to delete an empty folder i got "the dirctoy name is invalid" Support 3
C How to bypass UAC warning when shortcut in \Startup folder ? Support 9
CWBillow Clearing out the Windows Temp folder Support 2
J directory or folder to start in Support 2
vefatica Refresh a folder in File Explorer? Support 0
P How to? Delete subfolders but not the folder itself Support 11
vefatica Shortcut/start-up folder nonsense Support 20
cgunhouse Crash on View/Folder Support 1
D Fixed Cut and paste in TC's file/folder view does not remove file Support 17
D Version 18 changed the naming convention of TC's folder Support 5
C How to? COPY ftp folder query Support 7
fpefpe How to? folder / explorer window Support 10
rps Documentation Folder combo box docs Support 1
J Startup folder Support 6
C DEL, connected Web folder, report Support 1

Similar threads