Last active
April 28, 2020 09:42
-
-
Save marufshidiq/f3f719089744607c970bf9ab50b196b8 to your computer and use it in GitHub Desktop.
ZIP multiple PDF and EXCEL
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
N_PDF=$(find ./PDF -type f -name "*.pdf" | wc -l) | |
N_EXCEL=$(find ./EXCEL -type f -name "*.xls" | wc -l) | |
echo '===== MRF ZIP =====' | |
echo 'PDF =' $N_PDF 'file' | |
echo 'EXCEL =' $N_EXCEL 'file' | |
if [ "$N_EXCEL" -ne "$N_PDF" ] | |
then | |
echo '[ERROR] PDF File and Excel File not equal' | |
read -p "[INFO] Press enter to exit" | |
exit 0 | |
fi | |
for EXCEL_PATH in ./EXCEL/*; do | |
FILE=$(cut -d'/' -f3 <<< $EXCEL_PATH) | |
FILENAME=$(cut -d'.' -f1 <<< $FILE) | |
PDF_FILE="./PDF/"$FILENAME".pdf" | |
if [[ -f $PDF_FILE ]] | |
then | |
zip.exe -j -qq "./ZIP/$FILENAME.zip" "$EXCEL_PATH" "$PDF_FILE" | |
# ./zip.exe -j -qq "./ZIP/$FILENAME.zip" "$EXCEL_PATH" "$PDF_FILE" # Windows download zip from http://stahlworks.com/dev/zip.exe | |
echo '[SUCCESS] ZIP Created '$FILENAME'.zip' | |
else | |
echo '[ERROR] File '$FILENAME' not found' | |
fi | |
done | |
echo '[SUCCESS] Done' | |
read -p "[INFO] Press enter to exit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment