rename every 9th file

Bulk Rename Utility How-To's

rename every 9th file

Postby cvhmanchester » Fri Feb 07, 2020 7:37 pm

I am trying to find a more automated method of selection from 1000s of files. The camera takes (and saves) 8 focused stacked photographs then constructs a composite image which is named next in the sequence. I am taking a time lapse sequence of ca 200 images. I want to choose only those 200 composites, i.e. every 9th file.
This can be achieved by renaming every 9th file by, say, adding a C as the first character. I could then sort on C*, then copying and manipulating them further.

Is there a method of doing this? I am a novice in BNU, but a scan of the options does not look likely.
cvhmanchester
 
Posts: 4
Joined: Fri Feb 07, 2020 6:14 pm

Re: rename every 9th file

Postby bru » Sat Feb 08, 2020 12:16 am

Without knowing the name-formats, its impossible to say.
If you merely wish to rename every 9th-file, here's a batch for it:

@echo off
Set/p num= Process every n-th file ?
Set/a num="num", count=0
SetLocal EnableDelayedExpansion
For /f "delims=" %%A IN ('dir/b/a-d *.bmp') DO (Set/a count="count+1"
If !count! equ !num! (echo ren "%%A" "C%%A")&&(Set/a count=0))
pause>nul

When it prompts, enter 9 to see which files would be renamed if you remove echo from the batch.
Im sure there's a javascript method as well, but I dont have the paid version.
bru
 
Posts: 62
Joined: Wed Jan 31, 2018 7:35 pm

Re: rename every 9th file

Postby trm2 » Sun Feb 09, 2020 4:55 pm

From forthcoming 'Volume 2 Bulk Utility Operations Manual - Expert's Corner'

Will allow you to more easily identify the ‘Nth’ file for possible later selection or renaming or other action.

1. The procedure will be as follows:

a. Use Numbering to prefix an autonumber (section #10: Numbering)
b. Increment value will be ‘1’
b. Use a pad dependent upon the value of the ‘Nth’
c. Use a Break of 1
d. Sep (arator character) will be <space> for clarification

2. The ‘Nth’ file number will determine the pad value. Remember that pad will pad zeros so you have to think
in terms of decimal places - pad 2 for 10’s (2 decimal places), pad 3 for 100’s (3 decimal places), pad 4 for 1000’s
(4 decimal places) etc.

For example,

If you wanted to be able to identify every 7th file in a folder, the closest value would be 10, so pad = 2 for 2 decimal places.
If you wanted every 15th file, the closest value would be 100, so pad = 3 for 3 decimal places
If you wanted every 205th file, the closest value would be 1000 so pad = 4 for 4 decimal places

3. Determine starting value for the autonumber.

a. Subtract the value for ‘Nth’ from the closest value equal to the number of required decimal places (as determined by
the pad value above, again being 10, 100, 1000 etc.)

For example,

If you wanted to be able to identify every 7th file in a folder, the starting number is 10 – 7 = 3
If you wanted every 15th file, the starting number is 100 – 15 = 85
If you wanted every 205th file, the starting number is 100 – 205 = 795

3. The Break determines when the autonumber counter resets back to it’s starting value. Using a vlaue of ‘1’ indicates that
when the first character position of the autonumber changes, then reset.

i.e.

If the Autonumber starting value is set at 3, the break will occur when autonumber reaches 10 because that is when the
counter will go from 09 to 10, thus changing the zero value, the first character in the autonumber, from zero to one.

so the sequence will be::

03, 04, 05, 06, 07, 08, 09, 03, 04, 05, … etc.

For your example, every 9th file:

10 -9 = starting value 1 with pad 2, increment 1, sep = <space>, Break = 1

So every filename that beings with a prefix of 09 will be the 9th file

Don't forget that you must select the files in the Content Pane (the file list window) before the changes can be seen in New Name column.


based on an original concept by JMM
Don't forget to pick up your free copy of Volume I in How-To Section of Forums.
trm2
 
Posts: 156
Joined: Wed Jan 15, 2020 12:47 pm

Re: rename every 9th file

Postby trm2 » Sun Feb 09, 2020 9:22 pm

Link to Volume 1 Bulk Rename Utility Operations Manual in How-To Section:


viewtopic.php?f=12&t=4743
trm2
 
Posts: 156
Joined: Wed Jan 15, 2020 12:47 pm

Re: rename every 9th file

Postby bru » Sun Feb 09, 2020 9:34 pm

Nice post trm2
Your reply is much more user-friendly than my batch.
That's especially true if one needs to match the 1stFile and then every nth afterwards

Here's another way with #10Numbering
Mode=Prefix, Start=1, Pad=2, Break=1, Incr=1, Sep=---
Then set the Type's Base=(n+1) (Every9thFile:Base10, Every15thFile:Base16, etc)
bru
 
Posts: 62
Joined: Wed Jan 31, 2018 7:35 pm

Re: rename every 9th file

Postby trm2 » Mon Feb 10, 2020 1:40 am

Sounds good - I will try it when I get a chance - give me till the middle of this week and I will let you know. Sorry to not do it
sooner - I am tied up with writing and I also have to reply back to another user who is waiting on me.

Thanks, Bru
trm2
 
Posts: 156
Joined: Wed Jan 15, 2020 12:47 pm

Re: rename every 9th file

Postby bru » Mon Feb 10, 2020 12:32 pm

@trm2
No worries. Nice work on the manual btw! Quite the noble effort, I think many will benefit.
I've already posted something learned from it (regex case-insensitivity): viewtopic.php?f=11&t=4009
I've used case-insensitivity, but didnt realize BRU could implement it.
Looking forward to Volume2!
bru
 
Posts: 62
Joined: Wed Jan 31, 2018 7:35 pm

Re: rename every 9th file

Postby trm2 » Mon Feb 10, 2020 3:11 pm

Thanks I appreciate that.

Admin wants me to remind people to post their comments, feedback, suggestions, errata, etc. to

viewtopic.php?f=12&t=4743

So if you wouldn't mind - reposting that comment to that link - They and I would appreciate it - trying to motivate foot traffic there.


I guess I will have to do the same with my replies as well (I will hear back from TGRMN on that shortly)

As soon as you post your comment there - I can reply further concerning the Volume II Book.


Again, Thanks. The next reply coming up in this posting, 'rename every 9th' will be about getting back on your technique using the Numbering - I am testing it now.


See ya shortly.
trm2
 
Posts: 156
Joined: Wed Jan 15, 2020 12:47 pm

Re: rename every 9th file

Postby trm2 » Mon Feb 10, 2020 3:32 pm

Works fine. Added to Volume II.
trm2
 
Posts: 156
Joined: Wed Jan 15, 2020 12:47 pm

Re: rename every 9th file

Postby cvhmanchester » Mon Feb 10, 2020 7:46 pm

Thank you. That is a really fast response. It is a really simple problem - if you know what you are doing.
So much better than <cntl><click> 200 times.

When does V.II hit the virtual shelves?

I realise that the control page is very crowded, and you have other things on your mind. Could there be a help button on each section that takes the (novice i.e. me) user to the relevant page in the operations manual? Or at least mention somewhere up front in Help that there is a manual or II.

Tip of the day "File Numbering is the 9th Operation" - not according to the control page "Numbering (10)"
cvhmanchester
 
Posts: 4
Joined: Fri Feb 07, 2020 6:14 pm

Re: rename every 9th file

Postby trm2 » Mon Feb 10, 2020 8:10 pm

I Really shouldn't comment on the manual here, but if you are referring to the 'Order of Expression Evaluation' page 22, it
does not follow in order of 1-14.. this information comes from BRU's original manual page 11. You see it starts with the Import of Rename-Pairs
which is designated as step 1 and not part of the designated criteria sections specifications. It then continues through to character translation
as step 5 and case which would be 'section #4: Case', is performed as step 6, rather than step 4. By the time you get to Numbering it is step #12 and not step 10.

If, however, you are referring to another part of the manual, that could indeed be a typo, please give me the page number so I can check it out. I would correct
it for the next revision. I have noticed a few typos and have been correcting them as I see them, but unfortunately, I am not able to make the updated version
available until I have enough significant changes.

Again, I must refer you to viewtopic.php?f=12&t=4743 so I can comment further. I want to hear from you about
anything you wish to discuss concerning the book, but it must be done using that link. I will respond.
trm2
 
Posts: 156
Joined: Wed Jan 15, 2020 12:47 pm


Return to How-To