I exported all of my personal daily notes from my previous job, taken in Notion, over almost three years. The export was well-structured, but not very nice to look at or edit in a text editor, because each day was exported in its own file. I used fish shell
on the command line to rename the files and directories and combine some of the files.
A further improvement could be to rename the daily notes to be ##-Day
instead of Day-##
so that the days would be in order in the compiled files. I decided to not do this right now since I plan to edit the collated files down to essential summaries of tasks, so the order of the days isn't terribly important. This is all to help me update my LinkedIn/resume description for my past job.
2021 b66912b4b62d499aab303e5ecf48e052/
├─ January 344309c9fec64bcc8296025112a5691d/
│ ├─ Week 01 bf2bf63b13ad4ce38b780b1d6b8c0383/
│ │ ├─ Monday 04 369b1290b92540908b3a1926bf54acd7.md
│ │ ├─ Tuesday 05 23ffbc8ef39640d1bfb395a977104ccc.md
│ │ ├─ ...
│ ├─ Week 02 5471003441e04783be84f83a418282bd/
│ │ ├─ Monday 11 35fdf92223294f17bc4d8c33077c8545.md
│ │ ├─ ...
│ ├─ ...
├─ February 1735c8e4ee354be9b545619daa9ca2d0/
│ ├─ Week 01 666023d3c46e4a9e99926971c4af5588/
│ │ ├─ Monday 01 6e0fc07a92a54b12b3c48f5581df775a.md
│ │ ├─ ...
│ ├─ ...
│ ...
for file in **/*.md;\
echo (basename $file .md)\
| string match -r '^(\w* ){0,2}'\
| string trim\
| read output;\
set path (dirname $file);\
mv $file "$path/$output.md";\
end
Results
2021 b66912b4b62d499aab303e5ecf48e052/
├─ January 344309c9fec64bcc8296025112a5691d/
│ ├─ Week 01 bf2bf63b13ad4ce38b780b1d6b8c0383/
│ │ ├─ Monday 04.md
│ │ ├─ Tuesday 05.md
│ ├─ Week 02 5471003441e04783be84f83a418282bd/
│ │ ├─ Monday 11.md
├─ February 1735c8e4ee354be9b545619daa9ca2d0/
│ ├─ Week 01 666023d3c46e4a9e99926971c4af5588/
│ │ ├─ Monday 01.md
for dir in (find . -d -type d); echo $dir |
if test $dir != '.';
string replace -r '(\w*)$' '' $dir |
string trim |
read output; mv $dir $output;
end;
end;
Note: the above could be improved by passing a depth paramter to find
and removing the if-statement
Results
2021/
├─ January/
│ ├─ Week 01/
│ │ ├─ Monday 04.md
│ │ ├─ Tuesday 05.md
│ ├─ Week 02/
│ │ ├─ Monday 11.md
├─ February/
│ ├─ Week 01/
│ │ ├─ Monday 01.md
Function to compile all of the daily notes within a week folder into one file
function compileNotes
pwd |
string match -r '[ \\w]*$' |
read output; set filename "../$output compiled.md";
echo "# $output" >> $filename;
for file in ./*.md;
cat $file >> $filename; echo \n\n >> $filename;
end;
end
Run the above function within a year folder to traverse into each month folder and compile all of the daily notes into a single file
for dir in (find . -d 2 -type d); echo $dir |
if test $dir != '.';
cd $dir; compileNotes; cd -;
end;
end;
Results
2021/
├─ January/
│ ├─ Week 01/
│ │ ├─ Monday 04.md
│ │ ├─ Tuesday 05.md
│ ├─ Week 01 compiled.md
│ ├─ Week 02/
│ │ ├─ Monday 11.md
│ ├─ Week 02 compiled.md
├─ February/
│ ├─ Week 01/
│ │ ├─ Monday 01.md
│ ├─ Week 01 compiled.md
For each month directory with compiled weekly notes, combine the weekly notes into a single file for the month.
for dir in (find . -d 1 -type d);
echo (string match -r '[ \\w]*$' $dir) | read output;
set filename "$output compiled.md";
echo "# $output" >> $filename;
for file in $dir/**compiled.md;
cat $file >> $filename;
echo \n\n >> $filename;
end;
end
Final results
2021/
├─ January/
│ ├─ Week 01/
│ │ ├─ Monday 04.md
│ │ ├─ Tuesday 05.md
│ ├─ Week 01 compiled.md
│ ├─ Week 02/
│ │ ├─ Monday 11.md
│ ├─ Week 02 compiled.md
├─ January compiled.md
├─ February/
│ ├─ Week 01/
│ │ ├─ Monday 01.md
│ ├─ Week 01 compiled.md
├─ February compiled.md
Now there's twelve note files for each year, instead of 365 files. \o/