#1 : 06/01-25 11:49 Jim
Posts: 7
|
I find the List Method truncates the input folder names from the last period found and all characters after that, even though they are folders, not files with dot extension etc.
My requirement is to batch rename many eBook author folders named "firstname lastname" into "lastname, firstname". Using the List Method, clicking Populate list will populate the source folder listing that I can copy and paste into Excel for the name manipulation, and then paste the adjusted folder names back from Excel into Advanced Renamer for executing the renaming. Unfortunately there are many author folders named J.R.R. Tolken, James P. Hogan, etc., and the aforementioned List Method quirk of truncating the names based on the last period character messes up the listing. It does not matter if there is a previous Method in the Method sequence to replace . with _ or whatever, the subsequent List Method does not care the previous Method will make that change. There are workarounds but it makes the entire process awkward. It would be much simpler if the List Method does not apply last period truncation when sources are folders rather than files. |
#2 : 06/01-25 12:34 Kim Jensen
Administrator
Posts: 948 |
Reply to #1:
I am not entirely sure what is going on. Can you send me a screenshot showing the problem? You can find my email address by clicking the Support menu item. |
#3 : 06/01-25 13:02 Miguel
Posts: 170
|
Reply to #1:
Hi Jim, Have you considered using regex? The Replace method might help you: Replace: ^(\w.+(?:\s\w\.)?)\s+(.+)$ EDIT: This method is simpler and seems to work just as well: ^(\w.*) (\w.*)$ Replace with: \2, \1 Check to use regular expression. Apply to Name Happy New Year! Miguel |
#4 : 07/01-25 17:52 Jim
Posts: 7
|
Reply to #3:
Thanks. I tried your approach, and it works most of the time. Unfortunately some author last names are two words, such as: L. Sprague De Camp => Camp, L. Sprague De Daniel Da Cruz ==> Cruz, Daniel Da Margaret St. Clair ==> Clair, Margaret St I suppose I can treat those cases as additional given names rather than part of the last name (per your solution). In my Excel spreadsheet of formulas and macros, I handle those special cases, output: De Camp, L. Sprague Da Cruz, Daniel St. Clair, Margaret My Excel macros for the manipulations is fairly painless. I simply invoke my PASTE macro, and it paste from clipboard what I copied from the List Method window, then it manipulates and put the manipulated result back into the clipboard, ready for pasting back into the List Method window, replacing what I copied. |
#5 : 07/01-25 19:41 Delta Foxtrot
Posts: 401
|
Reply to #4:
Hi Jim, welcome, It's really rather trivial dealing with the various name permutations, but without knowing what your files *actually* look like I can't give you a definitive answer. I'm assuming that your filenames contain more than just a series of author names; they probably have titles, maybe other stuff like publish date, etc. And that's why we always ask that submitters give us actual examples of actual filenames, so we can devise actual solutions. Can you please supply representative actual filenames so that we can advise you on your actual situation? Given just author names, a series of four cascading replace methods solves the problem, but given more information in the filenames that basic solution will fail. Also, there will probably be other name permutations, edge situations, that will break the basic solution without planning for them. Thanks, looking forward to more information. Best, DF |
#6 : 07/01-25 21:21 Jim
Posts: 7
|
Reply to #5:
Hi. Sample list of folder names to be converted to lastname, givennames: dir * 2025-01-07 02:02 PM <DIR> . 2025-01-05 10:26 PM <DIR> Charles De Linit 2025-01-05 10:26 PM <DIR> Daniel Da Cruz 2025-01-05 11:54 AM <DIR> David Drake 2025-01-05 11:21 PM <DIR> David Weber 2025-01-05 10:27 PM <DIR> G. C. Edmondson 2025-01-05 10:22 PM <DIR> George R. R. Martin 2025-01-05 10:30 PM <DIR> J. G. Ballard 2025-01-05 10:18 PM <DIR> J.R.R. Tolkien 2025-01-05 11:54 AM <DIR> James P. Hogan 2025-01-05 10:27 PM <DIR> L. Sprague De Camp 2025-01-05 10:17 PM <DIR> Lois McMaster Bujold 2025-01-05 10:20 PM <DIR> Margaret St. Clair 2025-01-05 10:28 PM <DIR> Paul Di Filippo 2025-01-05 10:20 PM <DIR> S. M. Stirling 2025-01-05 10:16 PM <DIR> Shana Abe-Dakon === as mentioned in my Repy to #4, I considered combo lastnames such as Da Cruz St. Clair Di Filippo De Linit Van Vogt St. James My current Excel macro considers the second last word in the name to be part of the last name if: Da De Di Le St. Van I would add additional "special second-last words" to my lookup array if I encounter any more in the future. |
#7 : 08/01-25 02:20 Delta Foxtrot
Posts: 401
|
Reply to #6:
Hello again, Jim I'd forgotten you were working on directories, so I realize now you DO only have author names in the folder name. How do you get that final period to "stick" when Windows doesn't allow the last character to be a period or a space in a file or folder name? Anyway, here's what I got. It takes five replace methods in the method list, and looks mildly complicated, but it seems to work well and, once you get it installed, should allow you to just load your folder names, press start, and be done. All methods use regular expressions, and Case sensitivity can be checked. All apply to name, and all occurrences. 1. Replace: ^([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)$ Replace with: $3 $4, $1 $2 2. Replace: ^([^ ]+) ([^ ]{2,3}) ([^ ]+)$ With: $2 $3, $1 3. Replace: ^([^ ]+) ([^ ]+)$ With: $2, $1 4. Replace: ^([^ ,]+) ([^ ,]+) ([^ ,]+)$ With: $3, $1 $2 5. Replace: ^([A-Z])\. (.*)([A-Z]?)$ With: $2 $1. $3 (All replace strings start with the caret and end with the dollar sign) The period-at-end problem threw me for a minute. I solved it by using a non-printing character at the end of the replace strings on methods 2, 4, and 5. The character I used was Alt+0141 (hold down Alt key and type 0141 on the keypad). I don't know about your localization but I assume this will work on any English set. You can not use this solution, but then (unless you have another way to do it) you won't get periods on the initials when they are at the end of the folder names. EDIT: Oh, by the way, this won't work if you run into last names like "de La Cruz" or "Della Sera". If that's the case we'll have to add another method to fix them. END EDIT Screenshot: https://drive.google.com/file/d/1aF6H_0UBZTk2ueC 4Pse65KC1gklXDLj-/view?usp=sharing Good luck, let me know if you have problems. Be sure to save the batch so you can call it up without having to re-enter it. :) Best, DF |
#8 : 08/01-25 05:39 Jim
Posts: 7
|
Reply to #7:
Thanks Delta Foxtrot. I tried your batch solution and it worked exactly the way you described. My current collection of author folders do not have periods at the end if initials, so I would have to modify your solution to not have them. I am mystified how you got the lastnames with prepositions e.g. "Da Cruz" to work as a preposition lastname; but, very nice. I did email reply to Kim Jensen this morning with my screenshots. Regardless of my problems with handling author names, the bugs with the List Method should still be fixed, namely: a) for folders, List Method (Populate list) is truncating the the name based on the last period found in the name. I can see where that is used with filenames to strip the extensions, but should not do it for folders. b) the List Method (Populate list) is not respecting the result from previous Methods; the "Populate list" button appears to be using the original values in the righthand window Table Column "Foldername" rather than the previous Methods-manipulated results in Table Column "New foldername". Specifically Method 1 - Replace all . with _ Method 2 - List (Populate list) Yield problematic output as if the periods are still there, hence not using the results of previous methods in the batch. Just add Method 6 - List (Populate list) to the solution you gave me and you can see what I mean (all previous methods ignored). Foldername "J. G. Ballard" ==> NewFolderName "J. G" |
#9 : 08/01-25 08:46 Delta Foxtrot
Posts: 401
|
Reply to #8:
Hey Jim, I know that there are problems in the version 4 updates with periods. I have documented another problem in script methods with them, which I relayed to Kim as well. Just please be patient with progress on problems in the new version. As a former Director of Information Systems for a large petroleum company, I know how much work is involved in creating a new base version of a program. And I had a team of programmers working for me; Kim is doing this pretty much on his own. It is a Herculean task, and he is doing a great job. I'm not sure why, but periods have been a problem both in the 4.x release and also in the 3.x versions. I'm sure Kim will deal with them in time, but in the meantime, I assure you there is nothing out there better than Advanced Renamer (and I have tried everything available). And no, I don't get anything for saying that. :) By the way, you don't have periods after initials in your folder names? I wish you'd told me that; it would have made the solution actually a little simpler. And your example folder names all had periods, so... ? Best, DF |
#10 : 08/01-25 14:29 Jim
Posts: 7
|
Reply to #9:
Thanks for the feedback. I tried to remove the trailing period from your solution but had no success in figuring out where you placed the invisible Alt+0141 characters. The only way I was able to remove the trailing dots in Column "New Foldername" was to remove the dot in your Method 5 "With" statement, thus (note the dot removed after $1) Original 5. Replace: ^([A-Z])\. (.*)([A-Z]?)$ With: $2 $1. $3 Modified 5. Replace: ^([A-Z])\. (.*)([A-Z]?)$ With: $2 $1 $3 Nevertheless, with YOUR ORIGINAL SOLUTION when I clicked "Start batch" to actually make the changes, I see in Windows Explorer there are NO trailing dots in the renamed folders, regardless of the fact Advanced Renamer column "New Foldername" implied there would be trailing dots. I created a test folder containing a few matching author subfolders with the visible character names manually typed, and then copied the Adanced Renamer modified author folders there, Windows Explorer merged the matching folders in test (rather than showing up as additional folders with hidden characters), implying it sees no distinction. |
#11 : 08/01-25 14:56 Jim
Posts: 7
|
Reply to #10:
BTW Delta Foxtrot, I just ran across an author name that threw me off (trailing Jr): L. E. Modesitt Jr. I created a folder named "L. E. Modesitt Jr" (without the trailing dot), and applied your solution there. Your solution yielded "Modesitt Jr, L. E", which is perfect. My Excel macro solution would have considered "Jr" as the last name. as "Jr, L. E. Modesitt". :) No idea how your Replace expressions does its magic. I then created a test folder "L. Modesitt Jr" (just 3 words rather than 4) Your solution yielded "Jr, L. Modesitt" |
#12 : 08/01-25 18:25 Delta Foxtrot
Posts: 401
|
Reply to #10:
Hey Jim, I didn't include invisible characters in the solution I placed on the forum. I wasn't sure if you'd want to use that trick; that's why I explained what I did, in case you wanted to add the characters on your own. And by the way, if you do want to do that you should add the non-printing character on all methods except the first (and then try them out to make sure that's right). :) And yes, Windows does not allow a period or a space as the final character of a file or folder name. Thanks, Bill. ARen does show those characters, however, so you just have to be aware of the OS limitation. Reply to #11: Here's a method that should fix various problems with name suffixes, although I have to caution you that it may break other fixes (I'm thinking where a person has two last names plus a suffix; should be a very rare occurrence anyway). Replace Method 6: Replace: ^(Jr|[IV]+|Esq|M.?D)(\.?), ([^ ]*) (.+)(\.?)$ With: $4$5 $1$2, $3 (same rules apply as previous methods. You could add the non-printing character to this one, but since Windows doesn't keep trailing periods it won't make any difference) As to how this batch works, it's really fairly simple (and the basis for a lot of stuff I do in ARen outside of scripting). Start with the broad changes. Add methods in such a way that each only works on names that match a certain group of names, then add more methods with greater specificity that, insofar as possible, don't break the previous methods. Last, fix any breakages created by the previous methods. :) At this point, unless I've missed something incredibly obvious–and it happens all the time, believe me–I would add a List Replace method to fix very specific problems (like the two-last-name-plus-suffix thing I mentioned above). Best, DF |
#13 : 09/01-25 17:12 Jim
Posts: 7
|
Reply to #8:
For the record, I am retracting my complaints about the List Method (Populate list) issues. Kim Jensen emailed his reply that explained the issues I encountered. a) the List Method has the "Apply to:" option at the bottom, which I did not see because the default Advanced Renamer opening window size on my PC did not show the full List Method partition sub-window (bottom part hidden) until I either expanded the Advanced Renamer window or scroll down on the List Method partition sub-window. Choosing "Apply to: Name and extension" rather than the default "Apply to: Name" resolved the problem I ran into. With the "Name and extension" selected, button "Populate list" copies the original folder names as is, without applying any filters that truncated from last period onward, per folder. Not that intuitive (labeling) of that option on folders, but... I read the User Guide more carefully. The guide screenshot for the List Method does show the Applies to: option at the bottom. b) List Method ignores all preceding Method steps in the batch is design intent, using names either loaded from a file or original file/folder names via Populate list button. Kim was very polite and did not use words like "design intent"; I was less polite in the past when people commented on my approach to perform some programming operation. :) |