Find duplicates and rename by template

Advanced Renamer forum
#1 : 15/11-21 01:10
Eleven
Eleven
Posts: 1
Hello! Is it possible to implement such an idea?

I have a folder that contains subfolders. Some of the subfolders contain duplicate files. I need to implement a search for duplicates in these subfolders and rename them using the pattern "_ <Subfolder name>". At the same time, the rest of the files in the subfolders should not be affected.

It was just as great if the program could create the same subfolders by name in a separate folder and move the renamed duplicates into them. I am dealing with 20,000+ photos.

An example of files without renaming:
===
Folder "Example"
-Subfolder "Example2"
- "file.jpg"
- "file2.jpg"

- Subfolder "Example3"
- "file.jpg"
- "file3.jpg"
===
Final:
-Subfolder "Example2"
- "file_Example2.jpg"
- "file2.jpg"

-Subfolder "Example3"
- "file_Example3.jpg"
- "file3.jpg"
===

Or, for the program to transfer the renamed duplicates to another folder, keeping their subfolders:

- Folder "Example4"
- Subfolder "Example2"
- "file_Example2.jpg"

- Subfolder "Example3"
- "file_Example3.jpg"

Thank you in advance for your feedback.


15/11-21 01:10
#2 : 16/11-21 19:51
David Lee
David Lee
Posts: 1125
You can do this with a Script method.

First flag repeating file names by stepping through each filename in the list in the Pre batch script. Then in the main script append the folder name to all file names flagged as repeating.

Pre batch script:

var names = [];
n= app.itemCount;
for (j = 0; j<n; j++) {
name = app.getItem(j).name;
if (names[name]==0) names[name] = 1;
else names[name] = 0;
}

Main Script:

if (names[item.name]) {
return item.name + "_" + app.parseTags("<DirName>");
}




16/11-21 19:51 - edited 16/11-21 20:00