NODUP alternative

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

NODUP alternative

Postby therube » Fri Apr 09, 2021 9:14 pm

A possible alternative for /NODUP.
(Well, for my use case.)

You can use date/time "variables".
echo %date%: 04/09/2021
echo %time%: 15:40:14.79

You can "segment" those values, pulling out individual pieces.
So if you wanted 2-digit year, you'd use %date:~8% (or %date:~8,2%).
Or 4-digit year would be %date:~6% (or %date:~6,2%).

And with that, you can put together something like:
Code: Select all
BRC32.exe  /DIR:c:\tmp  /PATTERN:xxx_out.txt  /REMOVENAME  /FIXEDNAME:%date:~8,2%%date:~0,2%%date:~3,2%.%time:~0,2%%time:~3,2%.%time:~6,2%  /NODUP

and that outputs a filename like: 210409.1546.34.txt.

(For me), since I'm not likely to have this run more then once per second, I should be good.
And I've left the /NODUP in there to mop up if I happen to quicker then 1 second.


(In my case, all I really want is a numerically incrementing set of file names, that start at some number.
I don't care if they are not necessarily numerically sequential (1, 2, 3), only that the next number is larger then the previous).
And while /NODUP (alone) can do that, what happens is that I may delete a file, & when /NODUP next kicks in, the "nodup" part would end up using that deleted files name, rather then some "higher" name.
Like if my file sequences were: 2104_1, 2104_2, 2104_3, & I deleted 2104_2, then next file would be named 2104_2 rather then my wanted 2104_4, numerically higher. So when I then look at the file names, or perform some other operation on them, they're out of order - logically. Numerically, they're: _1 _2 _3, but logically, they're: _1 _3 _2, with _2 being the last output file, so while numerically lower, it's logically higher.)


Similar to above could be done with BRC's Custom Date Formats, only the Hour code, %H or %I, are not adjusted for ones Time Zone. [As it is, %time:% is based on a 24-clock, & that to me is awkward enough.])
therube
 
Posts: 998
Joined: Mon Jan 18, 2016 6:23 pm

Return to BRC Support