mirror of
https://github.com/hyzendust/encryptall.git
synced 2026-02-15 04:01:17 +01:00
Update: folder support
This commit is contained in:
@@ -9,18 +9,49 @@ echo ""
|
|||||||
PASSFILE=$(mktemp)
|
PASSFILE=$(mktemp)
|
||||||
echo "$PASSWORD" > "$PASSFILE"
|
echo "$PASSWORD" > "$PASSFILE"
|
||||||
|
|
||||||
for file in *; do
|
for item in *; do
|
||||||
if [ -f "$file" ] && [ "$file" != "Encrypted" ] && [ "$file" != "encryptall.sh" ] && [ "$file" != "encryptall" ]; then
|
# Skip the Encrypted folder and the script itself
|
||||||
|
if [ "$item" = "Encrypted" ] || [ "$item" = "encryptall.sh" ] || [ "$item" = "encryptall" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For folders, archive first
|
||||||
|
if [ -d "$item" ]; then
|
||||||
|
archive_name="${item}.tar.xz"
|
||||||
# Check if already encrypted previously
|
# Check if already encrypted previously
|
||||||
if [ -f "Encrypted/${file}.gpg" ]; then
|
if [ -f "Encrypted/${archive_name}.gpg" ]; then
|
||||||
echo "Skipping (already encrypted): $file"
|
echo "Skipping (already encrypted): $item/ (folder)"
|
||||||
else
|
else
|
||||||
echo "Encrypting: $file"
|
echo "Archiving folder: $item/"
|
||||||
gpg --batch --yes --passphrase-file "$PASSFILE" --symmetric --cipher-algo AES256 -o "Encrypted/${file}.gpg" "$file"
|
tar -cJf "$archive_name" "$item"
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "✓ Success: $file"
|
echo "Encrypting archive: $archive_name"
|
||||||
|
gpg --batch --yes --passphrase-file "$PASSFILE" --symmetric --cipher-algo AES256 -o "Encrypted/${archive_name}.gpg" "$archive_name"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✓ Success: $item/ (folder)"
|
||||||
|
# Remove the temporary archive file
|
||||||
|
rm -f "$archive_name"
|
||||||
|
else
|
||||||
|
echo "✗ Failed to encrypt: $archive_name"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "✗ Failed: $file"
|
echo "✗ Failed to archive: $item/"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# For files
|
||||||
|
elif [ -f "$item" ]; then
|
||||||
|
# Check if already encrypted previously
|
||||||
|
if [ -f "Encrypted/${item}.gpg" ]; then
|
||||||
|
echo "Skipping (already encrypted): $item"
|
||||||
|
else
|
||||||
|
echo "Encrypting: $item"
|
||||||
|
gpg --batch --yes --passphrase-file "$PASSFILE" --symmetric --cipher-algo AES256 -o "Encrypted/${item}.gpg" "$item"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✓ Success: $item"
|
||||||
|
else
|
||||||
|
echo "✗ Failed: $item"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user