How to combine multiple .md files into one .txt file.

When I exported all of my Apple Notes using Exporter from the Mac App Store, I ended up with a folder containing thousands of note files in the .md format.

I wanted to combine some of those notes together, so I separated them into different folders.

The following is an option to combine the .md files for each folder one by one. If you want to combine .md files across all or multiple folders at once, scroll down further below.


Combine .md files in each folder one by one

Step 1

Locate the folder containing the .md files. Press Alt, right click on the folder, and select “Copy [folder name] as a Pathname”.

Step 2

Open the Terminal app and enter the command below. Replace the highlighted path with the copied path of the folder, then press Enter.

cd /path/to/your/folder

Step 3

Copy and paste this command, then press Enter.

cat *.md > ~/Desktop/Notes.txt

The command above will combine the .md files into a .txt file named Notes.txt, stored on your Desktop.


Combine .md files across multiple folders all at once

Step 1

Move the folders into one folder.

Step 2

Press Alt, right click on the parent folder, and select “Copy [folder name] as a Pathname”.

Step 3

Open the Terminal app and enter the command below. Replace the highlighted path with the copied path of the folder, then press Enter.

cd /path/to/your/folder

Step 4

Copy and paste this command, then press Enter.

for dir in */; do

if [ -d "$dir" ] && [ -n "$(find "$dir" -maxdepth 1 -name "*.md" -print -quit)" ]; then

cat "$dir"/*.md > "${dir%/}.txt"

fi

done

The command above will combine the .md files into separate .txt files with names that correspond to each folder, stored in the parent folder where the folders are located.

Next
Next

How to remove unused options from select fields in Airtable.