How to Rename Images from it's Folder Name

I have some folder Like
Folder1
Folder2
Folder3 and so on
Every Folder has various Content like Flac, txt, jpeg, png, etc.
My Goal is Rename All the Images file Only (jpeg, png) with their parent's folder name.
As all Images in folder1 should be rename with
Folder1 (1).jpg
Folder1 (2).jpg
Folder1 (3).png
Folder1 (4).png

I had tried with this <from>(.*)\.(.*)</from> <to>{parent1}.\2</to>
It can rename selected file with it's parent folder name only but I want to select automatically all the Images files only, How to do that?

From (.*)\.(jpg|jpeg|png)
To {parent1}.\2

1 Like

I just test your code but this code gives an error dialog like the screenshot below
2020-07-16_7-30-54
I think this code can not create the 2nd file with the same name and add an incrementing number with the file name like
Folder1 (1).jpg
Folder1 (2).jpg
Folder1 (3).png
Folder1 (4).png

There's an option for that in the Rename dialog.
image

Jon I do not want use the rename dialog box in that case. I have tried to create a rename presets called RenameImagesfromFoldername.orp


and here is the RenameImagesfromFoldername.orp files code:

<?xml version="1.0" encoding="UTF-8"?>
<rename_preset case="none" fileinfo="yes" type="regexp" typeval="0">
	<from>(.*)\.(jpg|jpeg|png)</from>
	<to>{parent1} ([#]).\2</to>
</rename_preset>

And I use a tollbar button for using the rename preset

@nodeselect 
Rename PRESET="RenameImagesfromFoldername"

That option can be saved as part of the preset like all the other options.

1 Like

Dear Jon I don't Understand how to use the rename dialog, can you please tell me in details. I have tried with the rename dialog it's don't work for me. I know i am wrong.

Didn't you use the Rename dialog to create those presets?

No Jon. I just typed the rename preset

I'm not sure why you would want to do that rather than use the UI we've provided.

Add the autorename="yes" flag to the preset to turn on that option.

1 Like

Jon I had told you that I dont know how to use the UI of rename dialog box. Just look at the screen shot, i'm trying to use the rename dialog box but It's doesn't work.

You don't have the Mode set to Regular Expression by the looks of things.

How the Rename dialog works is documented in the manual.

Ok now I have set the mode to Regular Expression but It's not works

Turn off Ignore extension, since your pattern is looking for an extension.

1 Like

Thanks Jon now It's Works, but need a little tweaks (if possible)
It's Add a incremental number from the 2nd file, 1st file leave without number. like 1 folder have 5 jpg file, it's rename that to
demo.jpg
demo (1).jpg
demo (2).jpg
demo (3).jpg
demo (4).jpg
Look at this the incremental number is starting from the 2nd file. Is that possible to start the Incremental number starts from the first file? Like
demo (1).jpg
demo (2).jpg
demo (3).jpg
demo (4).jpg
demo (5).jpg

You can use the sequential numbering option to add sequential numbering that starts from 1, but it will do it in all cases, not just when the filename clashes. Your only other option would be a rename script.

Thanks Jon and Once again I am getting Stuck for a script. I can not write a script. If possible plz write a script for me if you have enough time for that. Thank u once again