Custom Date works in CMD window, not bat file

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

Custom Date works in CMD window, not bat file

Postby spenlinhauer » Wed Jun 25, 2008 9:06 am

Trying to create a script that will rename a file with a prefix of the file modified date.

Backup01.log = 2008-06-12 03`58pm backup01.txt

I was able to get this to work in a cmd window with:

BRC32.exe /APPENDDATE:M:P:" ":-:10:"%Y-%m-%d %I`%M%p" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE
I also tried useing the ~ between the hours and minutes both worked fine.

but putting that command in a .cmd file or .bat file would not work.
HOWEVER, using a date code of 9 worked ok.

BRC32.exe /APPENDDATE:M:P:" ":-:9 /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE
The problem is that creates a date & time code that is very hard to read with no formatting or spaces....

My hunch is that the BRC32 version is older than the windows version and doesn't have the date code 10 option, but if that is the case, why does it work from the cmd line manually?
Or is there a way to use a cmd line with the new version?

Great program and even better documentation - easy for an everyday user to get their head around....

SEPP!
spenlinhauer
 
Posts: 6
Joined: Wed Jun 25, 2008 8:47 am

Re: Custom Date works in CMD window, not bat file

Postby Admin » Wed Jun 25, 2008 9:22 am

Hi,

The command line version (BRC) and the Windows version (BRU) are completely separate products, so you need to refer to the correct documentation. It's highly likely that some functionality exists in one and not the other, and date format 10 could be one of these functions. I would need to check the documentation.



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

Re: Custom Date works in CMD window, not bat file

Postby spenlinhauer » Wed Jun 25, 2008 3:10 pm

According to the manual that was in the BRC32 zip file, it is supported in version 2.0.4.8 forward and according to the properties of the BRU32 file it is version 1.3.3.3 which means that it would/should not work, but it does work from a cmd prompt just not from the .bat file.

Is there another later version of the brc32.exe file that would work....

SEPP!
spenlinhauer
 
Posts: 6
Joined: Wed Jun 25, 2008 8:47 am

Re: Custom Date works in CMD window, not bat file

Postby Admin » Wed Jun 25, 2008 3:18 pm

Hi,

I'm not sure what you've downloaded, but the files on the website all look fine.

Bulk Rename Command, ANSI Build 1.3.3.0, for Windows 98/ME. 416,019 Bytes
Bulk Rename Command, Unicode Build 1.3.3.0, for Windows NT/2000/XP (32-bit)/2003 (32-bit)/Vista (32-bit). 423,102 Bytes
Bulk Rename Command, Unicode Build 1.3.3.0, for Windows XP (64-bit)/2003 (64-bit)/Vista

all contain the right manual, and all support the "format 10" for dates. I'm not sure where you are seeing this reference to 2.0.4.8. Please don't confuse BRU and BRC they are totally separate. The latest version of BRC is 1.3.3.3.



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

Re: Custom Date works in CMD window, not bat file

Postby spenlinhauer » Wed Jun 25, 2008 6:44 pm

OK, I understand that.

I do know that you have stopped development on this, so your help is appreciated.

This still begs the question as to why the /APPENDDATE date format 10 works ok manually at the command prompt but not when run from a script.

This is the command in my rename.cmd file:
BRC32.exe /APPENDDATE:M:P:" ":-:10:"%D-%m-%d %I`%M%p" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE

It does this:
backup01.log = m-I`p backup01.txt

If I put this in the rename.cmd file:
BRC32.exe /APPENDDATE:M:P:" ":-:9 /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE

It does this:
backup01.log = 08-06-24-15-36-51 backup01.txt

If I open a command line editor and run the first command line I get this - this is what I would like:
backup01.log = 2008-06-24 03`36PM backup01.txt

I thought that maybe the " " (Space) or the ` character were screwing it up, but it seems more that the :10: custom date format is what causes the mis-format.

Not sure where to go from here...
If I have to live with it, I could.....Just let me know - as you might have guessed I want to use this on NTbackup log files and it only saves 10 logs making historical evaluation impossible without renaming the files, so running this daily will solve the problem....


Thanks SEPP!
spenlinhauer
 
Posts: 6
Joined: Wed Jun 25, 2008 8:47 am

Re: Custom Date works in CMD window, not bat file

Postby Admin » Wed Jun 25, 2008 7:01 pm

I haven't tried it, but my feeling is that it's your ` character in the string. I suspect Windows is treating that as a delimiter otr something like that. Try without that character.



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

Re: Custom Date works in CMD window, not bat file

Postby spenlinhauer » Wed Jun 25, 2008 7:36 pm

If I try these "simple" custom formats:
BRC32.exe /APPENDDATE:M:P:" ":-:10:"%Y-%m-%d" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE
BRC32.exe /APPENDDATE:M:P:" ":-:10:"%Y" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE
BRC32.exe /APPENDDATE:M:P:" ":-:10:"%m" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE
BRC32.exe /APPENDDATE:M:P:-:-:10:"%m" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE

files are not renamed
spenlinhauer
 
Posts: 6
Joined: Wed Jun 25, 2008 8:47 am

Re: Custom Date works in CMD window, not bat file

Postby Admin » Wed Jun 25, 2008 9:43 pm

This is what I get:

Code: Select all
M:\Downloads\BRC64>BRC64.exe /APPENDDATE:M:P:" ":-:10:"%Y-%m-%d"


Processing Folder M:\Downloads\BRC64\
Filename BRC.chm would be renamed to 2008-06-03 BRC.chm
Filename BRC64.exe would be renamed to 2008-06-03 BRC64.exe
Filename BRC_Manual.pdf would be renamed to 2008-06-03 BRC_Manual.pdf
Filename BRCChangelog.pdf would be renamed to 2008-06-05 BRCChangelog.pdf
Filename pcre.dll would be renamed to 2008-01-17 pcre.dll


I'm using the 64-bit, but both 32-bit and 64-bit versions are compiled from the same source, just using a different compiler switch. This seems to be working okay.


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

Re: Custom Date works in CMD window, not bat file

Postby spenlinhauer » Wed Jun 25, 2008 10:42 pm

OK, now I am really confused...

how do you get a log file of that when the command is run from a .cmd file?
I can't even see the cmd screen when it opens and closes, its too fast...

Again, if I run that script manually from a command line, it works fine.
If I put the same script in a file and run it, it doesn't work right with the custom date.

Is there a way to save a log file or have the command window stay open?
Am I supposed to have the pcre.dll in a certain place?
could there be some other option or file that perhaps my machine does not have?
Maybe I missed installing something that is required?

I have also tried running this from our server, which is 64 bit, and I am having the same problem....
I must be missing something here...
Date format 9 works ok, date format 10 does not - regardless of the actual parameters.

SEPP!
spenlinhauer
 
Posts: 6
Joined: Wed Jun 25, 2008 8:47 am

Re: Custom Date works in CMD window, not bat file

Postby GMA » Wed Jun 25, 2008 10:44 pm

Hi:
I'm afraid that spenlinhauer is right in that the exact same line (when using the "APPENDDATE" argument with custom format) doesn't work via a .BAT or .CMD file, but it does work when you execute the line directly form a CMD window.
However, there's a solution for you, spenlinhauer: create a shortcut for your "BRC32.exe" file. Then open it's properties and add the following to the "Target" field (with a space between "...BRC32.exe" and "/APPENDDATE..."):

/APPENDDATE:M:P:" ":-:10:"%Y-%m-%d %I'%M%p" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE

Then use that shortcut to rename. That should do the trick :)
Best regards,

Gabriel.
GMA
 
Posts: 91
Joined: Sun Dec 02, 2007 1:30 pm
Location: Argentina

Re: Custom Date works in CMD window, not bat file

Postby Admin » Wed Jun 25, 2008 11:12 pm

Yes exactly, I was just doing some testing myself.

The problem isn't with BRC, it's with the way Windows parses the .cmd and .bat files. I'm sure there's a number of ways round it,a dn thanks to GMA there's at least one!


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

Re: Custom Date works in CMD window, not bat file

Postby spenlinhauer » Wed Jun 25, 2008 11:15 pm

Gabriel,

Thank you, thank you - I was starting to feel beat down by my PC....

It does work - with one caveat - you can't schedule a shortcut - the scheduled task enters the actual program/file that the shortcut points to.

But the Schedule command is structured like a shortcut, so you can enter the shortcut command in the scheduled task window and also set the "start in" folder to make sure you deal with the right files....

I think we're cookin' now....

SEPP!
spenlinhauer
 
Posts: 6
Joined: Wed Jun 25, 2008 8:47 am

Here's the solution

Postby nosnoop » Mon Aug 04, 2008 5:50 pm

spenlinhauer wrote:I was able to get this to work in a cmd window with:
BRC32.exe /APPENDDATE:M:P:" ":-:10:"%Y-%m-%d %I`%M%p" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE
but putting that command in a .cmd file or .bat file would not work.


This is because "%" is a special character in Batch file and will not interpreted as such.
What you need to do is to use "%%" instead of "%" in a batch file. E.g.

Code: Select all
@ECHO OFF
BRC32.exe /APPENDDATE:M:P:" ":-:10:"%%Y-%%m-%%d %%I %%M%%p" /PATTERN:"backup*.log" /FIXEDEXT:".txt" /EXECUTE


That's it!
nosnoop
 
Posts: 1
Joined: Sun Aug 03, 2008 7:13 am

Custom Date works in CMD window not bat file

Postby Karapaz » Thu Jun 04, 2009 6:46 pm

Thanks for the advice on the settings.

One thing Im a little confused about concerning the Image Size. Should I use the preset that says 320 x 240 QVGA, or should I go to custom size and select 320 x 240 from there which leaves off the QVGA part. I dont know what QVGA is. Do I want that?

Thanks,

Randy
Karapaz
 
Posts: 6
Joined: Mon May 18, 2009 11:41 pm
Location: USA


Return to BRC Support