Spaces in pattern

Post any Bulk Rename Command support requirements here. Open to all registered users.

Spaces in pattern

Postby someoneabc » Wed Jun 23, 2010 2:30 pm

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!
someoneabc
 
Posts: 7
Joined: Sun Apr 29, 2007 3:22 pm

Re: Spaces in pattern

Postby Admin » Thu Jun 24, 2010 3:27 am

Hi,

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

thanks
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Spaces in pattern

Postby Stefan » Thu Jun 24, 2010 11:01 am

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
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Spaces in pattern

Postby someoneabc » Thu Jun 24, 2010 1:41 pm

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
someoneabc
 
Posts: 7
Joined: Sun Apr 29, 2007 3:22 pm


Return to BRC Support