Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # REMEMBER: We must be in the correct dir!
- # script will iterate through active directory and convert
- # text files (php|py|js) to pdf - copying the dir structure
- # postscript files reside in ../ps/ (interim, ending .ps)
- # pdf reside in ../pdf/ (ending .pdf)
- # depending on the amount of files it may take some time...
- # requirement enscript:
- if [ ! -x $(which enscript) ]; then
- echo "enscript is missing (sudo apt-get install enscript) - aborting!";
- exit 1;
- fi
- # requirement ps2pdf:
- if [ ! - $(which ps2pdf) ]; then
- echo "ps2pdf is missing (sudo apt-get install ghostscript) - aborting!";
- exit 1;
- fi
- # we look for .php|.py|.js files and convert them
- find . -type f \( -iname "*.php" -or -iname "*.js" -or -iname "*.py" \) -print | while read ORIGIN; do
- echo "$ORIGIN";
- BASE=${ORIGIN:1};
- PS=../ps"$BASE".ps;
- PDF=../pdf"$BASE".pdf; echo "$PDF";
- if [[ ! -d $(dirname "$PS") ]]; then mkdir -p $(dirname "$PS");fi;
- if [[ ! -d $(dirname "$PDF") ]]; then mkdir -p $(dirname "$PDF"); echo "$PDF";fi;
- enscript -o "$PS" "$ORIGIN";
- ps2pdf "$PS" "$PDF";
- done
- exit 0
Add Comment
Please, Sign In to add comment