Bulk file rename shortcut

I want to do something from “tinfoil hat” (in fact no, i just almost got caught on copying files because of the file name (please, do not ask why i need to hide this)).

Does anyone know how to make all selected files (preferably only pics, vids and docs) automatically clean all metadata and rename to something random like 0000-aaaaa-bbbb-cccccc-1111.png?

I know about Metadata cleaner with gui, I use it. But I’m interested in quick renaming of selected files in the directory. Preferably also by keyboard shortcut.

Hello,

For this you may try something like this:

WARNING: Always backup data first, no way back. Test, on backup data fist!!!

Create script the following script in the directory you wish to clean metadata on all images:

#!/bin/bash

shopt -s globstar nullglob

# File extensions you want to process (add more as needed)
extensions=("jpg" "jpeg" "png" "gif" "webp" "pdf" "docx" "xlsx" "mp4" "mov" "mkv")

# Loop through all files recursively
for ext in "${extensions[@]}"; do
  for file in **/*.${ext}; do
    [ -f "$file" ] || continue

    dir="$(dirname "$file")"
    base="$(basename "$file")"
    ext="${file##*.}"

    # Generate random name
    randname="$(printf "%04x-%05x-%04x-%06x-%04x" $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM).${ext,,}"

    # Clean metadata (suppress output)
    exiftool -overwrite_original -all= "$file" >/dev/null 2>&1

    # Rename safely
    mv -n "$file" "$dir/$randname"
  done
done

Make the script eg. strip-meta.sh executable:

chmod +x strip-meta.sh

Then run the script:

./chmod +x strip-meta.sh

Here is an example:

This script will interact with all images with the following extensions:

extensions=("jpg" "jpeg" "png" "gif" "webp" "pdf" "docx" "xlsx" "mp4" "mov" "mkv")

Change the above line to remove or add extensions.

Hope this helps

Lubos