Not sure if I should be posting in a new topic or not, but my problem is similar to the OP in this post: Parsing a Single Text File into Multiple Files - #12 by Aachoo2
I was hoping to modify this solution to fit my own needs. Although I am a KBM newbie I was able to follow many of the steps in this macro. I get lost in the regex, though.
Like the OP, I have a text file that needs to be split into into multiple files
My splitting delimiter is @@@ but I could change it to anything
I'd love it if the macro could do the following:
- Split the big file using the delimiter (might be nice to be able to customize this so more people could use the macro)
- If the first line of the split files is blank/whitespace, delete it
- Name the individual files using the first non-blank line
- Delete that line in the new file (so that each new file starts with the second non-blank line). In my example file to split below these are the lines with tags (i.e. #cat #pet)
- Save the processed individual files (I'm not picky about this part. They could be saved in the same folder or a new folder like in the solution provided to the OP)
Here's what a representative file to split might look like:
cat litter #cat #pet This is a fantastic litter that doesn't clump or smell It's available from fine pet products retailers everywhere @@@ dog litter #dog #pet This product doesn't exist. @@@ bird litter #bird #pet This is basically a bunch of old newspapers used to line a birdcage
Thanks in advance for any help.
P.S. I originally tried to do this in the new Mac Shortcuts app. Silly me.