Problem with removing digits from end of string (complicated)

Advanced Renamer forum
#1 : 14/05-20 14:06
Talha Yabanigül
Talha Yabanigül
Posts: 2
Hi all,

I have a big problem with removing some digits at the end of file name. Here is some of my files:

Files with same name (Cozumu_1 , Cozumu_2 , Cozumu_3)
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_1 _2_720
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_1 _03_360
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_1_1080
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_2 _2_360
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_2 _3_720
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_2_1080
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_3 _3_540
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_3 _30_720
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_3 _003_1080

i try to rename above like this:
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_1_720
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_1_360
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_1_1080
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_2_360
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_2_720
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_2_1080
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_3_540
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_3_720
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_3_1080


Files with not incresing digit at last
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri _2_360
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri _3_540
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri _4_720
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri_1080

i try to rename above like this:
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri_360
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri_540
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri_720
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri_1080

last parts are video heigt properties and this values must be on files. I can remove and add them later by <Video Height> tag. When i try to remove unnecessary digits, also the necessary ones removes. Ist it possible to make a rule for this.

Thanks and sorry for bad english.


14/05-20 14:06
#2 : 14/05-20 15:14
David Lee
David Lee
Posts: 1125
Assuming that your examples are representative of all your filenames you only need to remove occurrences of:

<space>_<number>

So...

Remove pattern
Pattern: " _\d+"
Use regular expressions

Don't include the quotes in the pattern



14/05-20 15:14 - edited 14/05-20 15:15
#3 : 14/05-20 15:42
Talha Yabanigül
Talha Yabanigül
Posts: 2
Reply to #2:

Sorry for my insufficient examples. I have to accomplish this other than using space in pattern. Because many other files are same but without spaces before "_"

Like:

Biyoloji_1_Hucre_Canlilarin_Temel_Birimi_Hucre_1_001_720
Biyoloji_1_Hucre_Canlilarin_Temel_Birimi_Hucre_1_002_1080
Biyoloji_1_Hucre_Canlilarin_Temel_Birimi_Hucre_1_3_360


14/05-20 15:42
#4 : 14/05-20 18:14
David Lee
David Lee
Posts: 1125
Reply to #3:

I'm assuming that the first part of the filenames (eg "Biyoloji_1_Genel_Tekrar_Soru_Cozumu") can take any values.

If so then we have a problem since it's not possible to determine whether a number should be removed from a filename that ends with two numbers.

So the penultimate number should be removed from:
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri _2_360
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri _3_540
Kimya_1_Atom_ve_Periyodik_Sistem_Atom_Modelleri _4_720

but not from files containing an incrementing digit:
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_1_1080
Biyoloji_1_Genel_Tekrar_Soru_Cozumu_2_1080

But the two sets of filenames are of exactly the same format (apart from the space)

Unless there is some other feature of the filename that we can use to distinguish between the two types of filename you will have to rename the files with and without the incrementing digit separately.

In each case use the Replace method with a regular expression...

With incrementing digit - use pattern ".*_\d*\K ?_\d*(_\d*)"
Without incrementing digit - use pattern " ?_\d+(_\d+)$"
(Enter the patterns without the quotes)

In each case Replace with: \1


14/05-20 18:14