renaming depending the first part of filenames before hyphen

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

renaming depending the first part of filenames before hyphen

Postby srazon7578 » Wed Feb 08, 2023 9:43 pm

Hi there.

I have been using BRU for a very long time its been like years.
But i have been using this very wrong!
I need a huge favor, which for me looks impossible to do, but any experienced guy could be in great help.

I have lots of images to be renamed in my folders,the image names are like this

Before: 1.jpg, 2.jpg, 3.jpg ...

When i have image like the scenario above (with no hyphens in my image names), i select all of them, then in numbering i define my start number (25) with increment (1) and remove the filename its self
After renaming : 25.jpg, 26.jpg, 27.jpg Viola :D

This method works but with no success with the scenario below

Scenario 2
1.jpg, 1-2.jpg, 2.jpg, 2-2.jpg, 3.jpg, 3-2.jpg, 3-3.jpg and so on...

Here i need to change only the first part of the files, the hyphen and the numbers afterwards are the 2. and 3. sub images of my items
I need to convert those image names like the numbers below
25.jpg, 25-2.jpg, 26.jpg, 26-2.jpg, 27.jpg, 27-2.jpg, 27-3.jpg
You can see that the only changing part of the file names is the first part before the hyphen, the second part after the hyphen is to be untouched.

And of course sometimes my old file numbers and the updated ones may intersect, i need to move every file to another folder (i prefer to open a new folder inside my folder which the images are)

I have no idea what Regex is, i looked at the documentation and its quit complicated but i could not find anything useful for me, maybe because i'm not experienced in it.
And looking at the operation manuals i saw that theres a way to do javascript programming, it could be my second solution. But i dont know Javascript :cry:

can someone please help me, that help will save me lots of time.
I need you help.

Thank you very much.
srazon7578
 
Posts: 4
Joined: Wed Feb 08, 2023 9:05 pm

Re: renaming depending the first part of filenames before hyphen

Postby therube » Thu Feb 09, 2023 4:58 pm

Find your dashed names (by some means).

5:Remove
Crop: Before, - (that's a dash)

10:Numbering
Mode: Prefix, Start: 25

Code: Select all
1-2.jpg   25-2.jpg
1-3.jpg   26-3.jpg
2-1.jpg   27-1.jpg
3-1.jpg   28-1.jpg
3-2.jpg   29-2.jpg


OK, forget that, it's not right.
It should be 25-3 & 28-2 (with 2-1 -> 26-1 & 3-1 -> 27-1).
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: renaming depending the first part of filenames before hyphen

Postby therube » Thu Feb 09, 2023 5:10 pm

Lets try:

3:Replace, First (checkmark)
Code: Select all
Replace:  1|2|3
With:  25|26|27

And just extend that for the number pairs that you need (4..5..6...).
Code: Select all
1-2.jpg   25-2.jpg
1-3.jpg   25-3.jpg
2-1.jpg   26-1.jpg
3-1.jpg   27-1.jpg
3-2.jpg   27-2.jpg
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: renaming depending the first part of filenames before hyphen

Postby srazon7578 » Fri Feb 10, 2023 10:59 pm

Ijust didnt expect to get an answer so quickly thank you!

Nice, seems working.
If i mess with the filenames, can i revert everything this method. Is this undoable? just wondered.

Now i have another problem 8)
Sometimes i work with 90 item fotos,
so listing 1|2|3| ... and on the other hand 225|226|227... will not be easy at all.
I would almost say that renaming all by hand could be easier.

So i need a way to generate me the "replace" and "with" keywords.
I got an idea like write a method in excel VBA using the start point to the endpoint (Cell A1 to A2)
But writing that in VBA screen is another challenge.

And another question if possible.
The moving option for the files, in case the new file names could intersect with the old ones (which is not favorable)
So i'm already selecting my folder that i work, i could use a"Temp" folder inside it, which could be generated by the program, and move things inside of it in order to get rid of files before they get me in trouble.
Does that even work like this? Or i have to select my folder every single time i change file names ?


Thank you very much
srazon7578
 
Posts: 4
Joined: Wed Feb 08, 2023 9:05 pm

Re: renaming depending the first part of filenames before hyphen

Postby therube » Mon Feb 13, 2023 6:34 pm

Note that at some point (I imagine) the length of text that the dialog accepts might be a consideration?


I've got this batch file (circa 1993), NUM.BAT (that I just happened to use, today):
Code: Select all
@echo off
rem  Num.bat numbers lines of a text file.

FIND "^&@*" %1 /n /v | FIND "-------- " /v

And I had this file that contained dates & payments, & said to myself, I wonder how many payments were made?
Code: Select all
       6/12/20                     2,500           
       6/19/20                     2,500           
        7/6/20                     2,500           
       7/17/20                     2,500           
        8/6/20                     2,500           
       10/8/20                     2,500           
       10/9/20                     2,500           
       11/3/20                     2,500           
      11/30/20                     2,500           
       1/11/21                     2,500           
       1/22/21                     2,500           
       2/23/21                     2,500         

So in Vim (a text editor), I did !!NUM.BAT

& gave me a file that looked like:
Code: Select all
[1]       6/12/20                     2,500           
[2]       6/19/20                     2,500           
[3]        7/6/20                     2,500           
[4]       7/17/20                     2,500           
[5]        8/6/20                     2,500           
[6]       10/8/20                     2,500           
[7]       10/9/20                     2,500           
[8]       11/3/20                     2,500           
[9]      11/30/20                     2,500           
[10]       1/11/21                     2,500           
[11]       1/22/21                     2,500           
[12]       2/23/21                     2,500         

From there, I could easily s/].*// to remove everything starting with ], & I could do likewise to remove up to the [.
From there, easily append a |. From there, Join all likes to a single line.

UNIX cat, can also number lines, cat -n

How to suggest otherwise, oh, not sure, particularly?
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: renaming depending the first part of filenames before hyphen

Postby therube » Mon Feb 13, 2023 6:37 pm

Renaming Options, has a Prevent Duplicates setting that would "prevent duplicates" ;-) that might help with "intersect", depending on the situation.

(Always test, to make sure what you expect to happen, does.)
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: renaming depending the first part of filenames before hyphen

Postby srazon7578 » Fri Mar 03, 2023 10:39 am

Hi there,

In sorry i was away for 2 weeks.
I just found out you reply, i'm sorry that i wasn't able to reply.

what you were writing about, i have no idea :-) , i'm sorry,

But found another way!
I wrote that exvel VBA is complicated to use for a non-programmer person

I created an event for of my excel sheets.

Code: Select all
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Application.CutCopyMode = False Then
Application.Calculate
End If

If Range("A7").Value = "x" Then
    Dim cell As Range
    Dim str1 As String
    Dim str2 As String
    Dim rng As Range
   
    Set rng = Selection 'This will set the range to the currently selected range
   
    For Each cell In rng
        If cell.Column = rng.Columns(1).Column Then
            If Len(str1) = 0 Then
                str1 = cell.Value
            Else
                str1 = str1 & "|" & cell.Value
            End If
        Else
            If Len(str2) = 0 Then
                str2 = cell.Value
            Else
                str2 = str2 & "|" & cell.Value
            End If
        End If
    Next cell
   
    Range("F7").Value = str1
    Range("F8").Value = str2
   
    Else
    Range("F7").Value = ""
    Range("F8").Value = ""
   
End If
   
End Sub

What this code does is "when you do a selection between two columns" the evet grabs uper left, upper right, buttom left and buttom right cell values as variables
and prints F7 and F8 those values and the whole in between values with the "|" key.

For Example (think like its and excel file and you are selecting two neighbouring columns)

Then File Name desired My recent file name
381 1
382 2
383 3
384 4
385 5
386 6
387 7
388 8
389 9
390 10
391 11
392 12
393 13

Then these two cells will get this value automatically

F7 : 381|382|383|384|385|386|387|388|389|390|391|392|393|394|395
F8 : 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15

Job well done!!

But theres a problem!
I found out that after completing the 1 digits from 1 to 9 , have no problem, but when "Bulk Rename Utility" passes to "10 the values it produces 3910, 3911, 3912, 3913, 3914, 3915

I dont know why it is happenning.

Anyone has an idea?
srazon7578
 
Posts: 4
Joined: Wed Feb 08, 2023 9:05 pm

Re: renaming depending the first part of filenames before hyphen

Postby srazon7578 » Fri Mar 03, 2023 10:43 am

For some reason i couldn't edit my post

i needed to create a table inside the post.


Then File Name desired
381
382
383
384
385
386
387
388
389
390
391
392
393

My recent file name
1
2
3
4
5
6
7
8
9
10
11
12
13
srazon7578
 
Posts: 4
Joined: Wed Feb 08, 2023 9:05 pm


Return to BRU Support