Is this the best workflow to merge?

40 views
Skip to first unread message

David J

unread,
Aug 25, 2021, 3:17:46 PM8/25/21
to BBEdit Talk
Hello,

I have thousands of Markdown files in the same folder  I'm trying to merge so my elderly father can read them. File names are like samefilename (1), samefilename (2), samefilename (3).
I"ve been dragging and dropping all the samefilename.md (1, 2, 3, etc) into one bbedit tab. Then typing in samefilename.txt and saving it as one text. It's still quite time-consuming with thousands of files that are split up into threes, fours, etc in one folder.
Is there a better way of doing this? Possible to select: samefilename (1), samefilename (2), samefilename (3)  in Finder, merge and save as Samefilename.txt back to Finder? Seems like something terminal/bbedit could do?

With respect, David


MediaMouth

unread,
Aug 25, 2021, 3:40:06 PM8/25/21
to bbe...@googlegroups.com
What about a simple shell script?

cat file1 file2 file3 > newfile

On Aug 25, 2021, at 12:17, David J <future...@gmail.com> wrote:

Hello,
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/4e725ba2-bbc5-408f-8342-1c356fec843cn%40googlegroups.com.

jj

unread,
Aug 25, 2021, 4:21:16 PM8/25/21
to BBEdit Talk
Hi David,

1. Create a new empty document.

2. Then choose Menu Edit > Insert > File Contents ...

3. In the presented dialog click the bottom right "Options" button and check which options you want.

    [ ] Include separators

    [√] Ensure line break after each inserted file  (Highly recommended)

4. Select the files you want to insert.

5. Click insert and you are done.

You can repeat the operation if needed.

HTH

Jean Jourdain

David J

unread,
Aug 25, 2021, 6:15:24 PM8/25/21
to BBEdit Talk
Hi Harvey and Jean,

Jean, I tried your method and it's really great that I can insert files like that. I had no idea. What (it seems) I then have to do is go back to Finder and get the file name so I can save the merged files with the file name as the title. Where it starts to literally hurt is I have to do this thousands of times because the one folder has thousands of files that need to be merged, all with slightly different file names like:

Highlights for Zen and the Art of Motorcycle Maintenance by Robert M. Pirsig 3.md
Highlights for Zen and the Art of Motorcycle Maintenance by Robert M. Pirsig 4.md
Highlights for Zen and the Art of Motorcycle Maintenance by Robert M. Pirsig 5.md
Highlights for Zen and the Art of Motorcycle Maintenance by Robert M. Pirsig 6.md
Highlights for Zen and the Art of Motorcycle Maintenance by Robert M. Pirsig.md      <----- hoping for end result of 3-6 merged like so into one file with that title. Same for all files in the same directory with similar names like below:

Highlights for Zero History by William Gibson(1).md
Highlights for Zero History by William Gibson(2).md
Highlights for Zero History by William Gibson.md

Highlights for The Hitchhiker's Guide to the Galaxy by Douglas Adams(1).md
Highlights for The Hitchhiker's Guide to the Galaxy by Douglas Adams(2).md
Highlights for The Hitchhiker's Guide to the Galaxy by Douglas Adams.md

Journal John's bday (1)
Journal John's bday

Random thought jan 7 (1)
Random thought jan 7 (2)
Random thought jan 7 (3)
Random thought jan 7

The shell script is a little out of my knowledge, I'll do a little more reading. Was advised to also try:

"You can do this by putting the files in a folder and using cat *.md >>../somefilename.md should concatenate them to a new file one level up."

But seeing how the files are varied and slightly different like the above directory example. Using      *.md >>../somefilename.md   would merge everything into one file name? Was hoping there's some way to merge everything in the folder with similar files names into there similar file names.

I'm trying to get my elderly father much of my thoughts, highlights, journals while he's still around so I do appreciate the help 🙏

David G Wagner

unread,
Aug 25, 2021, 8:23:08 PM8/25/21
to BBEdit Talk
Oh, there is, but we would need someone with Applescript knowledge which could take a folder of files, have a new folder made to hold all the concatenated files until you are sure they are correct. They should be able to find all files of similar naming convention, concat the files, provide a simple report of the new files, write them to the new folder(could write to fame folder, but to me, would be easier review. 

So, yes, it can be done with a script...

Wags ;)
WagsWorld
Hebrews 4:15
Ph(primary) : 408-914-1341
Ph(secondary): 408-761-7391
Reply all
Reply to author
Forward
0 new messages