Adding last 4 characters of the folder name to file name

Advanced Renamer forum
#1 : 29/04-19 14:21
Mary Hughes
Mary Hughes
Posts: 2
I am trying to add the last 4 characters of the FOLDER name to the FILE name.
Folder Name: Great Movie - 2005
old File Name: Great Movie.avi

I want it to be: New file name: Great Movie 2005.avi

Please Help



29/04-19 14:21
#2 : 29/04-19 21:50
David Lee
David Lee
Posts: 164
So you want to add a space followed by the last 4 characters of the folder name to the existing filename.

I think that the easiest way to do this would be in two steps;

1. Add a space followed by a suitable marker character and the entire folder name.
2. Remove all characters starting from the marker except for the final four.

I suggest that you choose a marker character that cannot appear in a legal Windows filename (eg ":")

Step 1 - "Add" method:
Add " :<DirName>"
At index: 0
√ Backwards

Step 2 - "Replace" method:
Text to be replaced: ":.*(?=.{4})"
Replace with: leave blank
√ Use regular expressions

In the regular expression, (?=.{4}) is a "lookahead" - it matches the final 4 characters ".{4}" but does not "capture" them so that they are not included in the string to be replaced with blank.

Note: Do not copy the quotation marks in the text strings above.


29/04-19 21:50
#3 : 30/04-19 04:02
Mary Hughes
Mary Hughes
Posts: 2
Reply to #1:
That did not work.

Here is my FILE name: Great Movie.avi
Here is my FOLDER name: GREAT MOVIE - 2010

Here is my desired outcome for the FILE name: Great Movie (2010).avi

I don't really care about the Uppercase Folder name. I just want the date and the parenthesis at the end of the file name.



30/04-19 04:02
#4 : 30/04-19 06:51
David Lee
David Lee
Posts: 164
Reply to #3:
"That did not work" is no help whatsoever! The procedure works perfectly for me - I can't be of any more assistance unless you confirm exactly what you are doing and what results you are seeing.

You have also changed your desired outcome - initially there was no requirement to add parentheses.

Make sure that you follow this procedure exactly:

Firstly - the assumption is that the file Great Movie.avi exists within the folder GREAT MOVIE - 2010 and you copy the filename to ARen's list.

Create an Add method in a new method list
Add: " (:<DirName>)"
At index: 0
√ Backwards
Don't enter the quotation marks and note the space before the opening parenthesis.

The New Filename should display in the list as Great Movie (:GREAT MOVIE - 2010).avi but will be displayed in red since it is not a valid Windows filename.

Now add a Replace method to the same method list
Text to be replaced: ":.*(?=.{5})"
Replace with: leave blank
√ Use regular expressions

This will operate on the result of the Add method and should return the New File: Great Movie (2010).avi as required.



30/04-19 06:51