Check if file contains name off list and if it's not in the front of the file add it there

Advanced Renamer forum
#1 : 01/02-18 22:03
ubuttnoit
ubuttnoit
Posts: 2
I have a lot of files with peoples names in random places in the file names. I want to type out a list of those people names and scan the files to spot them. If the names aren't in the front of the file in the format "(First Name) (Second name) - " Then rename the file with that new format.


Is it possible to do something like that with scripting?


01/02-18 22:03
#2 : 02/02-18 03:11
Brian Hanlon
Brian Hanlon
Posts: 29
Reply to #1:
The Human brain is pretty good at picking out Names from a random list of words/pseudo-words, but to get AR to do it, you'd have to find a consistent pattern. - Are all names surrounded by braces?, are all OTHER 'words' less than three alpha characters before a numeric?, are the 'Names' the ONLY sets of pure alpha characters between spaces? Once you can discover a pattern, then you can script AR to do the actual Renaming, but the Analysis is up to you.

Brian.

----------
If this brilliant little tool has saved you time, or helped get your files in a better order, or just cleaned-up the crazy names from downloaded files, maybe you could donate a Dollar or Ten to Kim?
See https://www.advancedrenamer.com/download


02/02-18 03:11
#3 : 02/02-18 15:03
ubuttnoit
ubuttnoit
Posts: 2
Reply to #2:

Can't you make an array and see if the file name contains any text from inside the array?


02/02-18 15:03
#4 : 06/02-18 16:27
Brian Hanlon
Brian Hanlon
Posts: 29
Reply to #3:
To develop a JS solution to any awkward problem such as this, I'll usually pop to a command prompt, issue: 'DIR /B >>FILELIST.TXT', import that text into a spreadsheet and play with scripting on that. - Much safer than experimenting on live files, and when I have a successful JS, I can transfer it to AR for use on the actual files.

It depends to a great extent on how many files you have, and how many names are involved.

Something which needs to be taken into account is just HOW those names are recorded. - Are they ALL separated by just a space (simplest to handle), or are some formatted 'Surname, Given' or even 'Surname (Given)' possibly even 'Given_Surname'. Such variations can create the need for a lot of pre-processing. Then we can get such variants as: 'John+Betty Smith' or 'Smith, (John+Betty)' - all of which can create headaches.

A briefly tested RegExp Ruleset is as follows:

Swap all odd characters to a tilde:
1. Replace: ',\!\@\(\)\+\-\_' with: '~' (tilde) - ALL

Get rid of those tildes:
2. Replace: '\~+" (one or more tildes) with ' ' (space) - ALL - [x] Use Regular Expressions.

Place two dummy words as first words, just in case the name(s) is/are at the beginning:
3. Newname: 'not not <Name>'

Find a Surname:
4. Replace: '(.*) (\w*) (SURNAME01|SURNAME02|SURNAME03) (\w*) (.*)' with '\3 \1 \2 \4 \5' - [x] Use Regular Expressions.

Find a Given name:
5. Replace: '(.*) (GIVEN01|GIVEN02|GIVEN03) (.*)' with '\2 \1 \3' - [x] Use Regular Expressions.

Get rid of the Dummies:
6. Replace: 'not ' with '' (nul, nothing) - ALL

Rule 4. uses the Dummy words as fillers if needed, as either of \2 or \4 might hold the Given Name, which Rule 6. will find and place as the new FIRST word.

Give it a whirl on some COPIES!!! first, and do NOT hit 'Start Batch' unless the proposed changes look good.

Brian.

----------
If this brilliant little tool has saved you time, or helped get your files in a better order, or just cleaned-up the crazy names from downloaded files, maybe you could donate a Dollar or Ten to Kim?
See https://www.advancedrenamer.com/download


06/02-18 16:27