Feature Request: Conditional Replace

Advanced Renamer forum
#1 : 19/04-24 19:37
Michael
Posts: 4
I've been an avid user of Advanced Renamer for years, and one of the main issues I encounter is the inability to apply commands (e.g. REPLACE) to files that do NOT include a specific substring. Alternatively, I often have to apply commands to filenames that only include specific substrings in the name.

In the example below, I would like to apply a REPLACE command to filenames that do not include the substring "trailer." So in the example below, the REPLACE command would only execute against the second item in the list.

- file name trailer.mp4
- filename.mp4
- blah trailer.mp4

I encounter this sort of scenario all of the time (that impacts many commands and there's no easy way to get through this without a lot of manual manipulation. Adding this logic would make Advanced Renamer infinitely more powerful.

edited: 19/04-24 20:47
#2 : 19/04-24 22:25
Delta Foxtrot
Posts: 324
Reply to #1:

Hi Michael,

There's an easy way to do that. At the end of the method list add a replace method that lists all your keywords to "de-specify". In the "Replace with:" entry field put "<Name>" (without quotes). That removes any changes.

For example:

Text to be replaced: .*(trailer|buzzard|funny).*
with: <Name>
All occurences
Regex: YES
Apply to: Name

...removes all changes on files in which any of those words occur.

And it doesn't have to be at the end. I can be anywhere in the method list, after which you can do other stuff (that may only apply to files with those keywords).

https://drive.google.com/file/d/1hJ7vh3fyFWE0JnZ hmjgpPttjd8uDB_Ux/view?usp=sharing

Here I've done some changes in the first method, then undone them for my keywords, then moved all dates at start of filename to after the body (before incremental number).

Cheers,
DF
#3 : 20/04-24 01:27
Michael
Posts: 4
Reply to #2:

Thanks DF,

I'll try my best to elaborate further and apologize if this comes out as a long rant. :-)

I had previously tried variant of what you suggested (using other logic), but it didn't work the way I hoped it would. The problem stems from method list, which contains 17 methods that have to be executed in sequence. The output is modifying the filename grammar to meet the exact nomenclature specifications for another application that has to ingest and process the files based on their names. Any defects will cause the files to be rejected. For context, one batch job could have 8,000+ files.

Your solution works perfectly for situations where a filename with a specific keyword is excluded from ALL methods "preceding" the de-specify method. However, my method list has to exclude specific methods that are not grouped together. For example keyword 1 may exclude methods #1, #7, #14, and include method #7, while another keyword will have another subset of methods that are excluded and/or included. Given the disjointed nature of the methods that have to "turned-off" for each filename, the only in-app solution would be a conditional inclusion/exclusion command on a per-method basis if a specific substring is identified.

The only way I can successfully run this at present is to us Windows Explorer to filter the subset of files for a specific keyword, import that subset into Advaned Renamer, and then uncheck the appropriate methods. Then I have to repeat this process for the 10 or so naming variants in the batch job.

Your solution did teach me some new tricks however. I'm using your approach to simplify/streamline some of the more complex logic in my method list -- for this, I thank you!

edited: 20/04-24 01:41
#4 : 20/04-24 03:44
Delta Foxtrot
Posts: 324
Reply to #3:

Michael,

I absolutely understand. I do a lot of database work and have to get large datasets in shape to load into specific fields (for which the original creators had no inkling of what would happen to their data in the future). Not to try to "out-difficult" you–just so you know I can relate–I have method-lists of anywhere from 30+ to over 200 methods that I run against file and folder sets of 7,000 up (the last big rename I did was 22,000 files, and that's only because I've found that over Kim's default of 25,000 files response gets very molasses-like).

Here's another trick I use. Instead of using explorer or some other search tools–and I'd use Voidtools Everthing if it could ever seem to find my NASes–I use the right-click "Mark/Unmark" facility in ARen. It's not perfect, but I can touch a lot of files with the "by pattern" options, and if you've got a decent clipboard enhancer it doesn't take long to pop in several patterns. I've converted a lot of that work to the method I explained in my first response, but I still have to do several iterations of the mark tool. But at least it gets all the files in so I can look at them and see that at least the first few (hundred) previews look correct. And it's nothing to work through the unmarked files, marking them with a specific pattern to rerun with different options.

What I'd like to see is a programmatic way to mark/unmark. Sort of like replace or list replace, but instead of replace it would activate or deactivate the touched files. A couple of those scattered through the method list would be awesome. Or maybe a goto... method (if match, go to this spot).

Just some thoughts... at any rate, good luck my friend.

Best,
DF
#5 : 20/04-24 08:02
Kim Jensen
Administrator
Posts: 929
Reply to #1:
At first hand I would recommend the mark/unmark by pattern feature to include and exclude which files are to be batched, without removing files from the list that are not needed. But as I understand your reply, what you need is a condition on the method level. In Advanced Renamer you can activate or deactivate a method with a simple click, but it is an on/off setting. Is it correct that what you need is for this active checkbox to conditional per file based on the pattern of the filename?
#6 : 20/04-24 08:54
Michael
Posts: 4
Reply to #4:

Thanks again DF. I will look into some of your recommended apps. You've got me beat on data complexity. I yield!

edited: 20/04-24 08:55
#7 : 20/04-24 08:54
Michael
Posts: 4
Reply to #5:

Yes, your understanding of what I am proposing is correct. If each method contains a checkbox to activate a conditional rule (i.e. logic test) that would either "execute" or "skip" the method based on whether the condition is TRUE or FALSE, that would allow mixed filename patterns to flow through the same unmodified method list without conflict and avoid having to parse large batch jobs into multiple smaller jobs.

If you take this to an extreme (in some down-the-road version), adding a menu to select different conditional rules for each method would provide an unprecedented level of granularity to help normalize disparate data with varied filename patterns.

edited: 20/04-24 08:56