Rename Directory with filename from within the directory

Advanced Renamer forum
#1 : 07/04-21 22:30
Samantha
Samantha
Posts: 3
Hi,
I would like to replace the name of all folders with the name of the nth file with extension 'xyz' within that folder. Is that possible already? If not, one could make a tag like <filename:n:xyz>.
Cheers,
sam


07/04-21 22:30
#2 : 09/04-21 21:41
Samantha
Samantha
Posts: 3
Reply to #1:
I could also imagine a tag like <filename:abc:xyz>, where abc is the first occurrence of an xyz file with the String 'abc' in the filename (regex patternmatching may be a bit too complicated, given that nearly nobody will use it ...).

xyz should be optional ... writing <filename:n(or abc):> would be a file without extension and <filename:n(or abc)> would be a file with any extension.

Any comments?


09/04-21 21:41 - edited 09/04-21 21:42
#3 : 10/04-21 08:59
David Lee
David Lee
Posts: 1125
Reply to #2:
It's not as straightforward as you think - you also would have to define what you mean by "the nth file" - there are multiple ways that the contents of a folder could be ordered. Also it is unreasonable to expect the developer to add every conceivable obscure feature that an individual user may occasionally want to use!

However you can achieve what you wish using fairly simple scripting and command line automation, with ARen operating on one folder at a time.

Load the contents of an individual folder into the list with the desired ordering of files.

In the Pre batch script extract the filename of the nth file in the list with the desired extension:

Then in the main script set the newPath of each file using the name extracted in the Pre batch script.

Save the Script method as a method file (.aren) and use the "Command line configuration..." tool to automate the process of loading and ordering a folder and running the script method.

Finally edit your Windows batch file to step through all your folders, run the ARen command line on each one and delete the original folder.



10/04-21 08:59 - edited 10/04-21 09:00
#4 : 10/04-21 22:49
Samantha
Samantha
Posts: 3
Reply to #3:
Thanks for the reply. Actually, I don't think it matters too much (of course it is not the SAME), how you order them, as in several cases you can try a little back an forth or add other methods to get the desired result. It would be a step closer to have any file name generally from inside the folder.

Cheers for the proposed solution. I normally do not script much, so I have to invest a little more time into this, though surely less than renaming all of them by hand.


10/04-21 22:49