Reputation: 953
I have a directory full of org-mode files. Each file is structured into multiple trees like the following.
This is the first file
* First item
** Subitem 1
** Subitem 2
* Second item
I want to combine all of these files into a single file, where each file has it's own tree. So it would look something like this.
* file1.org
This is the first file
** First item
*** Subitem 1
*** Subitem 2
** Second item
* file2.org
This is the second file.
** First item
** Second item ...
What is the easiest way to make this happen using elisp?
Upvotes: 2
Views: 204
Reputation: 9437
This can certainly be improved, but should work pretty well:
rm combined.org tmp.org ;
for i in *.org ; do
touch combined.org ;
echo "* $i" > tmp.org;
sed "s/^\*/**/" "$i" | cat combined.org tmp.org - > combined.org.tmp ;
mv combined.org.tmp combined.org ;
done
Upvotes: 2