Append folder name as prefix while keeping part the file name

Advanced Renamer forum
#1 : 19/03-23 23:01
SunMan
SunMan
Posts: 3
What a wonderful software! Thanks I appreciate it to the fullest.

I spent too long for an answer for this possibly simple problem, but can't find an answer.

I would like to append the folder name as prefix while keeping part of the file name, if its possible.

For example:-

From folder
Movie name (2015) [Br.Hd2.H10b.Ec8.C.S-SunMan]

Files
Movie name 1 (2015) [Br.Hd2.Hevc.Ec3.8ch-SunMan].mkv
Movie name 1 (2015) [Br.Hd2.Hevc.Ec3.8ch-SunMan].nfo
Movie name 1 (2015) [Br.Hd2.Hevc.Ec3.8ch-SunMan]-fanart.jpg
Movie name 1 (2015) [Br.Hd2.Hevc.Ec3.8ch-SunMan]-poster.jpg

I'd like to rename the files as follows, which is really the folder name plus the -fanart or the -poster in the end.
Movie name (2015) [Br.Hd2.H10b.Ec8.C.S-SunMan].mkv
Movie name (2015) [Br.Hd2.H10b.Ec8.C.S-SunMan].nfo
Movie name (2015) [Br.Hd2.H10b.Ec8.C.S-SunMan]-fanart.jpg
Movie name (2015) [Br.Hd2.H10b.Ec8.C.S-SunMan]-poster.jpg

I have hundreds of these, if not thousands. Would be too difficult to do manually.

If, and when you get a chance, please instruct in detail.

Thanks in advance.


19/03-23 23:01 - edited 19/03-23 23:47
#2 : 20/03-23 03:05
David Lee
David Lee
Posts: 1125
Replace: [^]]*\]
with: <DirName>
Use regular expressions


20/03-23 03:05
#3 : 20/03-23 18:25
SunMan
SunMan
Posts: 3
Reply to #2:

OMG, you're the greatest. Works like a charm.

I did not sit tight after posting the question. I had come up with a really long but single click workable solution, which you might have a laugh with. I am going to write here just for the fun. But I'll be using yours which is quickest and shortest, using just a single function. Bravo!

Replace: .*?([a-z]*-poster)
with: \1
Use regular expressions

Replace: .*?([a-z]*-fanart)
with: \1
Use regular expressions

Add: <DirName:1>
at index: 1

Remove pattern: <Name>
apply to: name

I told you it was long, lol.

You're doing a great service to the community. Needless to say, but keep up the good work.

Edit:-
An observation:
The short solution works only if you want to keep anything after "]". Of course that is the perfect answer to my asked question. But I thought it would be asking too much by throwing other scenarios, where "]" would not be present in the file name. My fault. I figured that other readers would benefit by reading this experience.

I will be using both solutions.


20/03-23 18:25 - edited 21/03-23 01:16