How to rename files with 2 streams of finite numbers

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

How to rename files with 2 streams of finite numbers

Postby Zero01 » Wed Jul 05, 2017 2:43 pm

Hi,

I have various files (mainly image files) I would like to rename with two separate integers in the filename, where for instance a whole bunch of .bmp files would become 0x0.bmp. 0x1.bmp... up to say 0x10.bmp, then more files in the same folder would be 1x0.bmp, 1x1.bmp, 1x2.bmp.... 1x10.bmp... until the last set of files are 10x0.bmp, 10x1.bmp, 10x2.bmp.... 10x10.bmp.
So i'm wondering if i could do this all in one hit so to speak, perhaps using the Numbering option with the Mode "Pre. + Suff." and what else would I have to check/uncheck (tick/untick) etc... given that I've just downloaded this obviously marvelous software but am having trouble figuring it out. Thanks. :)

EDIT: the original files would have various different names but would have to be completely re-named i.e. no part of the original name in the new filename(s).
Zero01
 
Posts: 3
Joined: Wed Jul 05, 2017 2:30 pm

Re: How to rename files with 2 streams of finite numbers

Postby Admin » Thu Jul 06, 2017 1:54 am

You could do it in Javascript (section 12) in 1 pass. Javascript requires a commercial license. thanks
Admin
Site Admin
 
Posts: 1818
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to rename files with 2 streams of finite numbers

Postby Zero01 » Thu Jul 06, 2017 8:42 am

OK, thanks for the reply - why would I need a commercial license when I'm not a commercial entity? .. and as I'm not a programmer who can write or help write the syntax for me?
Zero01
 
Posts: 3
Joined: Wed Jul 05, 2017 2:30 pm

Re: How to rename files with 2 streams of finite numbers

Postby Admin » Thu Jul 06, 2017 8:54 am

Hello, try this script

Code: Select all
newName = (~~(counter / 10)+1) + "x" + counter % 10;


You can see the preview of the renames after you select all the files in the folder (and optionally subfolders).

If you like the script and want to use it, a commercial license can be bought from here:
http://www.bulkrenameutility.co.uk/Buy.php

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

Re: How to rename files with 2 streams of finite numbers

Postby Zero01 » Thu Jul 06, 2017 9:10 am

Yes that works (although it all should include "0" as the lowest value) so that's good to know. Well given that this is just for joining together pictures to form a larger image (via using a plugin) and it's not a pressing thing, just something for a hobby (art/image manipulation) I'll wait until I can save up enough pennies..... thanks again for the help!
Zero01
 
Posts: 3
Joined: Wed Jul 05, 2017 2:30 pm

Re: How to rename files with 2 streams of finite numbers

Postby Admin » Thu Jul 06, 2017 9:11 am

No worries, Javascript functionality is only supported under a commercial license.
Admin
Site Admin
 
Posts: 1818
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to rename files with 2 streams of finite numbers

Postby trm2 » Thu Feb 06, 2020 3:27 pm

Hello.

The solution provided does not account for 0x0 and at 0x10 it starts at 2x0. Here are two corrections:


This one is admittedly clunky:

part1 = (~~(counter / 11));
part2 = ((counter % 11)-1);
if (part2 < 0){
(part2 = 10);
(part1 = (part1-1));
}
newName = (part1) + "x" + (part2)


And here is a better one:

newName = (~~(object("autonumber") / 11)) + "x" + (object ("autonumber")) % 11;

This one requires 'Section #10: Numbering' with Mode at NONE and Start at ZERO.
trm2
 
Posts: 157
Joined: Wed Jan 15, 2020 12:47 pm

Re: How to rename files with 2 streams of finite numbers

Postby bru » Fri Feb 07, 2020 9:58 pm

And stealing from that logic ...
Here's a batch with brc32 that prompts the user to enter a LargestSuffix#:

@echo off
Set/p max=LargestSuffix# ?
Set/a pre=0, count=0, max="max"
SetLocal EnableDelayedExpansion
For /f "delims=" %%A IN ('dir/b/a-d *.bmp') DO ((Set name=%%A)&(Set name=!name: =?!)
If !count! leq !max! (brc32 /Pattern:!name! /FixedName:!pre!x!count! /Execute
Set/a count="count+1") ELSE ((Set count=0)&&(Set/a pre="pre+1")))
pause>nul

You can remove /Execute to preview what the renames would be.
For instance, if the user were to enter 2:

AnyName.bmp --> 0x0.bmp
AnyName.bmp --> 0x1.bmp
AnyName.bmp --> 0x2.bmp
AnyName.bmp --> 1x0.bmp
AnyName.bmp --> 1x1.bmp
AnyName.bmp --> 1x2.bmp
AnyName.bmp --> 2x0.bmp, etc
bru
 
Posts: 62
Joined: Wed Jan 31, 2018 7:35 pm

Re: How to rename files with 2 streams of finite numbers

Postby RegexNinja » Tue Mar 10, 2020 2:02 am

Hi, 'bru' here on a new account 'RegexNinja' (couldnt change the email).

It just dawned on me, the original poster may want to halt renaming after reaching 10x10.bmp
The original batch renames all .bmp's, possibly creating names like 11x0 - 11x10, and so forth.
Sorry, I completely missed that.

This batch includes an IF statement to halt renaming upon reaching the user's entered max.
(2:LargestRename=2x2.bmp, 4:LargestRename=4x4.bmp, 10:LargestRename=10x10.bmp, etc).
I also added a cd/d command to make it easier to change FolderPaths.
Sorry for any confusion.

@echo off
cd/d "YourFolderPath"
Set/p max=LargestSuffix# ?
Set/a pre=0, count=0, max="max"
SetLocal EnableDelayedExpansion
For /f "delims=" %%A IN ('dir/b/a-d *.bmp') DO ((Set name=%%A)&(Set name=!name: =?!)
If !count! leq !max! (brc32 /Pattern:!name! /FixedName:!pre!x!count! /Execute
If !pre! equ !max! If !count! equ !max! goto done
Set/a count="count+1") ELSE ((Set count=0)&&(Set/a pre="pre+1")))
:done
pause>nul
RegexNinja
 
Posts: 112
Joined: Fri Feb 21, 2020 5:26 pm

Re: How to rename files with 2 streams of finite numbers

Postby trm2 » Tue Mar 10, 2020 9:27 am

I'll also include this revision in your batch file.
trm2
 
Posts: 157
Joined: Wed Jan 15, 2020 12:47 pm


Return to BRU Support