summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-07-20 04:45:26 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-07-20 04:45:26 +0530
commit69ed6f893c6a39def9d19e8b636303b75eff48c3 (patch)
tree36c01c3274810069fe65ceb37061e149c62b4a90
parent5fa8df90badbc8520e0532e988e00954792a2d48 (diff)
.script: Exifclear script addition
-rwxr-xr-x.scripts/exifclear51
1 files changed, 51 insertions, 0 deletions
diff --git a/.scripts/exifclear b/.scripts/exifclear
new file mode 100755
index 0000000..3e85e86
--- /dev/null
+++ b/.scripts/exifclear
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# Function to prompt the user and get confirmation
+confirm() {
+ read -r -p "$1 [Y/n] " response
+ case "$response" in
+ [yY][eE][sS]|[yY]|"")
+ true
+ ;;
+ *)
+ false
+ ;;
+ esac
+}
+
+# Function to handle errors
+handle_error() {
+ echo "Error: $1"
+ exit 1
+}
+
+# Check if exiftool or exiv2 is installed
+if ! command -v exiftool &> /dev/null && ! command -v exiv2 &> /dev/null; then
+ echo "Neither exiftool nor exiv2 found. Please install either of them to proceed."
+ exit 1
+fi
+
+# Prompt the user for confirmation
+if confirm "Do you want to clear all Exif data metadata in the current folder and its subdirectories?"; then
+ if command -v exiftool &> /dev/null; then
+ # Run the exiftool command to clear metadata
+ if find ./ -type f -exec exiftool -all= "{}" \; ; then
+ echo "Exif data cleared successfully! still double-check if any metadata is present."
+ else handle_error "Failed to clear Exif data."
+ fi
+ # Remove files with names ending in "_original"
+ if find ./ -type f -name "*_original" -exec rm -rf "{}" \; ; then
+ echo "Files ending in '_original' removed successfully!";
+ else handle_error "Failed to remove '_original' files."
+ fi
+ elif command -v exiv2 &> /dev/null; then
+ # Run the exiv2 command to clear metadata
+ if find ./ -type f -exec exiv2 rm "{}" \; ; then
+ echo "Exif data cleared successfully! still double-check if any metadata is present."
+ else handle_error "Failed to clear Exif data."
+ fi
+ else handle_error "Neither exiftool nor exiv2 found."
+ fi
+else
+ echo "Operation cancelled."
+fi