#1 : 14/05-24 23:23 JayC
Posts: 4
|
I am trying to rename a batch of long file names (emails saved to a folder where their subject lines are now the "names" of the emails).
Some file names have a string like 'bob' or 'jim'. The placement is not fixed (i.e. I cannot simply use a place / count replacement method). Why this matters: I do not want to anonymize every email file; but I want to make sure that a user can easily locate the emails where 'bob' or 'jim' appear in the name. I want to rename the files with a fixed prefix and incrementally increasing number like, and also keep any bob or jim which may be found in the file name. Jay 001999 <Inc Nr:1> Bob Jay 001999 <Inc Nr:1> Jim But I am having trouble with the proper replace or remove method and/or regex to achieve this function. Does anyone have a suggestion? I have thoroughly reviewed the user manual. I am not remotely PCRE-literate but have made a stab at it with what I understand. |
#2 : 15/05-24 00:51 Delta Foxtrot
Posts: 364
|
Reply to #1:
Hi Jay, welcome, Sorry, this is not enough information to make a meaningful solution. What is Jay, what is 001999, how many names are you dealing with, do the names fall at any particular location in the filename, are the names delimited with specific characters, etc etc. A group of example "before" filenames, large enough so that we can infer the scope of the problem, would be useful, along with what you expect them to look like after transformation. I suspect you will need a script to approximate what you want, although depending on your filenames a series of replace methods might do most or all of it. So my final answer is, "that depends." :) Anxiously awaiting more information! Best regards, DF |
#3 : 15/05-24 01:48 JayC
Posts: 4
|
Reply to #2:
Hi DF, thank you. I have 207 files. Names are all over the map. The search string is always at the end of the file name as above [date_sender name_sender address_subject line]. The goal is to reach a renamed convention that follows this format: Jay 001999 [increment#] [Bob or Jim, if Bob or Jim present in original file name] E.g.: 2018-05-31__Buddy_ [email protected]__Fw_ Topic - Jim Stinks 2018-07-24__Kappa_ [email protected]__Topic- Bob Rocks 2018-06-05__Kappa_ [email protected]__RE_ walking upstairs Jim goes quiet 2018-07-30__Buddy_ [email protected]__Fwd_ Outside re_ Bob story development - Further Details 2018-06-05__InvestorServices_ [email protected]__Receipt And from these examples we would get to Jay 001999 1 Jim Jay 001999 2 Bob Jay 001999 3 Jim Jay 001999 4 Bob Jay 001999 5 As you see from example pattern above, first email name has Jim in subject line, second one has Bob, third one has Jim, fourth one has Bob, and fifth one is totally silent as to Jim or Bob, so it gets the standard prefix renaming. The renaming of this batch of files is to answer discovery requests from opposing counsel. Here, the prefix Jay 001999 is the arbitrary Bates-numbering format I chose for renaming a batch of EML files. Opposing counsel wants the EML files in a format like this with an increment for each e-mail. So, for example Jay 001999 1 all the way to Jay 001999 207. Opposing counsel would be very happy with that They do not care about the Jim or Bob being in the file name. But I do. For my purposes, I want to make sure I know which of these EML files explicitly involve Bob or Jim, so I can correctly identify them in the formal responses to their requests. [In law, we answer a request for production by identifying the specific file produced, and then we serve the file in question separately. It's important to know which files involve what topics so you can correctly list the responsive files in response to the requests for production.] So, to restate, I want to strip out the "Jim" and "Bob" references and append them to the renaming for all 207 files. Some might have Jim or Bob through this system and some might not. |
#4 : 15/05-24 06:29 Delta Foxtrot
Posts: 364
|
Reply to #3:
Hello again, See? A little context goes a long way. One replace method will get you what you want. REPLACE METHOD: (If you order your files by filename they will be in date order of sequence): Replace: ".*(Jim|Bob).*|.*" Replace with: "Jay 001999 <IncNr> $1" (WITHOUT THE QUOTES; there are only spaces inside the replacement text) Occurrence: all Case sensitive: no Regular expressions: yes Apply to: name Here's my screen preview before running batch: https://drive.google.com/file/d/13cEcGZc140E4lHO nJkmHD5wP47CSb8lb/view?usp=sharing I have to run but if you need an explanation of the command just drop me another message here. Or maybe it's moot? :) Best, DF |
#5 : 15/05-24 16:38 JayC
Posts: 4
|
Reply to #4:
My gosh, sir that's amazing work. My original syntax was nonsense: This was the replacement text I had tried ".*?(Jim|Bob).*" Replace with $1 [at time I was just trying to get the basic transformation to work] Pays to know the language. * I wish it was moot. However, I am not seeing the results expected. The specific search is Air and Morpheus. My new filenames, however, are not taking with the expected string. You can see, for example, at line item Mesa 001999 153 that the word "AIR" is present to the left (right after the date part of the file name), but AIR does not show. Similarly, AIR is present on Mesa 001999 145 and Mesa 001999 146 but not showing. https://drive.google.com/file/d/1P9TkVBxDB_k3ssI itjKQ4xjC9lECZ-0-/view?usp=sharing Assuming PICNIC. |
#6 : 15/05-24 17:33 JayC
Posts: 4
|
Reply to #5:
I'll keep the embarrassment up but yes the problem was indeed in the chair. I was running both NEW NAME and REPLACE so it seemed to prioritize the NEW NAME and couldn't force the REPLACE method into it. Removing the NEW NAME method and using only REPLACE, exactly as you said, worked. https://drive.google.com/file/d/1eZbnLK1b1O3TYUv MraxTnaWDxdT--3ed/view?usp=sharing I have seen the light of regex. I will be studying this and helping out where I can on this amazing community. |
#7 : 15/05-24 22:02 Delta Foxtrot
Posts: 364
|
Reply to #6:
Awww... BOOYAH! If I had a nickel for every time I'd done something similar I'd be in a higher tax bracket. Now go forth and use your newfound powers for Good. :) Best regards, DF |