Skip to content

Instantly share code, notes, and snippets.

@goooooouwa
Last active January 14, 2020 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goooooouwa/175a2301eb9c4bd4dceefeed1ce2e306 to your computer and use it in GitHub Desktop.
Save goooooouwa/175a2301eb9c4bd4dceefeed1ce2e306 to your computer and use it in GitHub Desktop.
break CardDiary export txt file into individual diary txt files with date as title. So that I can import these text files into Evernote.
# 1. Split file by seperator
# Copy tab key as is, not using escape char. It will find “Date” and use it as separator and not delete it.
gcsplit --digits=2 --quiet --prefix=outfile CardDiaryTXT.txt "/ Date/" "{*}"
# 2. Rename file based on content
for filename in *; do
echo $filename
mv $filename "$(head -1 $filename | cut -c 8-17) $(echo $filename | cut -c 8-)".txt
done
Date: 2018-09-25 16:29:58
Weather: Cloudy
Demo diary post 1
Date: 2018-09-26 19:05:07
Weather: Mostly Cloudy Day
Demo diary post 2
Date: 2018-09-26 19:05:07
Weather: Mostly Cloudy Day
Demo diary post 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment