Page 1 of 1

Spaces in pattern

PostPosted: Wed Jun 23, 2010 2:30 pm
by someoneabc
Hello!

I'm trying to write a batch file where every file (%1) that is dropped onto it is processed by BRC

Code: Select all
c:\brc32.exe /DIR:"%~dp1" /PATTERN:"%~n1" /REPLACECI:"#n:#new" /EXECUTE


example with variable content
%1 ... c:\testdir\test#n.txt
%~dp1 ... c:\testdir\
%~n1 ... text#n.txt

this works fine but only for files like "test#n.txt"
If the file contains spaces like "this is a test (2009) #n.txt"
BRC does not rename anything

Any ideas? Thanks!

Re: Spaces in pattern

PostPosted: Thu Jun 24, 2010 3:27 am
by Admin
Hi,

where is %1 used in the batch file?
what's %~dp1 ?

thanks

Re: Spaces in pattern

PostPosted: Thu Jun 24, 2010 11:01 am
by Stefan
Admin wrote:Hi,

where is %1 used in the batch file?
what's %~dp1 ?

thanks


%1 is used inside an batch to use the first parameter the batch is launched with.

parameter.cmd
Code: Select all
@ECHO OFF

ECHO  %1
ECHO "%1"
ECHO  %2
ECHO  %~2

ECHO %~d1
ECHO %~1
ECHO %~n1
ECHO %~x1
ECHO %~nx1
ECHO %~f1
ECHO %~f2
ECHO type in "for /?" for more ;-)
PAUSE
for /?

PAUSE


C:\path to\folder\>parameter.cmd file.txt "Spaces here.TXT"


I was able to use ^ undocumented escape char for /DIR:
/DIR:^"%~dp1^"

(or like this... I don't have my examples with me)


but this doesn't work for
/PATTERN:"%~n1"






I also tested double and thriple quoting """%~n1""" without success.


An workaround may be

Code: Select all
@ECHO OFF
%~d1
CD "%~p1"
SET FILE="%~n1"
ECHO %FILE%
/PATTERN:"%FILE%"
But still no success with /PATTERN

Re: Spaces in pattern

PostPosted: Thu Jun 24, 2010 1:41 pm
by someoneabc
Thank you so much for testing and your input!

Basically I'm trying to write a batch file that changes the filename of the dropped file.
It's only a single file and so I'm not sure if BRC is the right approach

But I'm stuck and I also don't understand why BRC works fine if there are no spaces ...

Maybe I will also try Autohotkey