From d441494fa71c54204684f9abcdc607c62096e8e9 Mon Sep 17 00:00:00 2001 From: hyzen Date: Sat, 17 Jan 2026 01:07:51 +0530 Subject: [PATCH] Add: previously encrypted check --- encryptall.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/encryptall.sh b/encryptall.sh index d5325a8..7cb962a 100755 --- a/encryptall.sh +++ b/encryptall.sh @@ -5,20 +5,24 @@ mkdir -p Encrypted echo -n "Enter password: " read PASSWORD -echo "Password length: ${#PASSWORD}" +echo "" PASSFILE=$(mktemp) echo "$PASSWORD" > "$PASSFILE" -echo "Temp file: $PASSFILE" for file in *; do if [ -f "$file" ] && [ "$file" != "Encrypted" ] && [ "$file" != "encryptall.sh" ]; then - echo "Processing: $file" - gpg --batch --yes --passphrase-file "$PASSFILE" --symmetric --cipher-algo AES256 -o "Encrypted/${file}.gpg" "$file" - if [ $? -eq 0 ]; then - echo "Success: $file" + # Check if already encrypted previously + if [ -f "Encrypted/${file}.gpg" ]; then + echo "Skipping (already encrypted): $file" else - echo "Failed: $file" + echo "Encrypting: $file" + gpg --batch --yes --passphrase-file "$PASSFILE" --symmetric --cipher-algo AES256 -o "Encrypted/${file}.gpg" "$file" + if [ $? -eq 0 ]; then + echo "✓ Success: $file" + else + echo "✗ Failed: $file" + fi fi fi done