Skip to content

Commit

Permalink
Create backup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
timosarkar authored Dec 12, 2024
1 parent 9509063 commit b8c49e4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions files/backup.sh
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

0 comments on commit b8c49e4

Please sign in to comment.