You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we run --export txt on a .epub the parts are automatically numbered, this is fantastic and very helpful. I usually delete the first 3 or something parts because they include the table of contents, the copyright page etc. This results in Part 4 being the first part.
I have a script that I use to cleanup the parts which is obviously very simple. It identifies all the lines that start with '# Part' and replaces them we a recount starting with 1. (Though the developer in me toyed with 0 index 😆 ).
Maybe it would be useful to include a script like this for a common usecase.
#!/bin/bash# Check if a file path is provided as an argumentif [ -z"$1" ];thenecho"Usage: $0 <file_path>"exit 1
fi# Assign the first command-line argument to file_path
file_path="$1"# Check if the file existsif [ !-f"$file_path" ];thenecho"File not found: $file_path"exit 1
fi# Initialize chapter counter
chapter_counter=1
# Read the file and process each linewhile IFS= read -r line;do# Check if the line starts with '# Part'if [[ "$line"=~ ^[[:space:]]*#\ Part ]]; then# Replace the line with "## Chapter X"echo"# Part $chapter_counter"
chapter_counter=$((chapter_counter +1))else# Output the original lineecho"$line"fidone<"$file_path">"${file_path}.tmp"# Replace the original file with the modified file
mv "${file_path}.tmp""$file_path"
The text was updated successfully, but these errors were encountered:
When we run --export txt on a .epub the parts are automatically numbered, this is fantastic and very helpful. I usually delete the first 3 or something parts because they include the table of contents, the copyright page etc. This results in Part 4 being the first part.
I have a script that I use to cleanup the parts which is obviously very simple. It identifies all the lines that start with '# Part' and replaces them we a recount starting with 1. (Though the developer in me toyed with 0 index 😆 ).
Maybe it would be useful to include a script like this for a common usecase.
The text was updated successfully, but these errors were encountered: