I gave up on this task. I’ll try to get back to it much later, probably writing the parser myself, and simplifying it significantly. Will come back to that later, and only then will write a proper post to my primary blog. Let this shit live here for a while.
- The original attempt was at 2024/08/01/1111.
- The 2nd attempt was at 2024/08/20/1307.
- This is the 3rd attempt.
So I updated the logic, and don’t rename files with their ids. I just rename the files and directories according to its creation time.
- Rename the files to dates.
- Insert links whenever it can.
- Insert toml-metadata.
- The rest is a manual work, I think.
1. Rename the files to dates
Prompt:
Very bad. Forget this script and write me another one.
I provide you a path that have markdown files and directories.
- Check every file in a given path
- Find the line that starts with the word
Created:
, e.g.:Created: December 12, 2016 9:10 AM
- Check whether the file has a directory counterpart with the same name (without the .md extension). E.g.
example-name
directory andexample-name.md
file. - Rename both directory and the file, follow this pattern: YYYY-mm-DD-HHMM for directory and YYYY-mm-DD-HHMM.md for a markdown file, where YYYY is the year, mm is the month, DD is the day of the month, HH is hours in 24-hr format, MM is minutes. E.g. 2016-12-12-0910. Take the date from
Created:
. - If there’s the file and directory with that name already, increase minute by one for both file and directory, e.g. 2016-12-12-0911, so the filenames would be unique.
- If there’s just a file and no directory with the same name, I’d like to rename the file with the same logic.
If it makes the renaming correctly, I’ll explore the links by myself, manually. There’s not so many attachments I’d like to actually keep.