-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9509063
commit b8c49e4
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# This script converts programming files (like .c, .py, .txt) into PDFs so I can print them physically as a very primitive backup stategy :) | ||
# Install: | ||
# sudo apt-get install enscript | ||
# sudo apt-get install ghostscript | ||
# Usage: ./backup.sh file1.txt file2.py | ||
|
||
# Function to convert a single file to PDF | ||
convert_to_pdf() { | ||
input_file=$1 | ||
output_file="${input_file%.*}.pdf" | ||
|
||
# Use enscript to convert the text file to PostScript | ||
# Remove unsupported options for page length and line spacing | ||
enscript --output=- --font=Courier8 "$input_file" | ps2pdf - "$output_file" | ||
|
||
echo "Converted $input_file to $output_file" | ||
} | ||
|
||
# Loop through all input files | ||
for file in "$@"; do | ||
if [ -f "$file" ]; then | ||
convert_to_pdf "$file" | ||
else | ||
echo "File $file not found." | ||
fi | ||
done |