For security reasons you should remove the meta data from files, which are publicly accessible.
We will use mat2 for this, so you should install it first:
apt install mat2
Now you can modify the snippet below:
#!/bin/bash
# Source folder where your files are located
source_folder="/home/pappz/Downloads/metatest"
# Check if the source folder exists
if [ ! -d "$source_folder" ]; then
echo "Source folder does not exist: $source_folder"
exit 1
fi
# modify the file with mat2, remove metadata and move it back to the original name
modify_file_function() {
# Get the file name and extension
filename=$(basename "$2")
extension="${filename##*.}"
filename_noext="${filename%.*}"
# Run mat2 to clean the file
mat2 "$file"
# Move the cleaned file back to the original name with the modified extension
mv "$1/$filename_noext.cleaned.$extension" "$1/$filename_noext.$extension"
}
# Iterate through files in the source folder
get_into_folder_function() {
for file in "$1"/*; do
# if it is a file, then modify it
if [ -f "$file" ]; then
modify_file_function "$1" "$file"
fi
# if it is a folder, then get into it
if [ -d "$file" ]; then
# make it recursive papa, yeah!
get_into_folder_function "$file"
fi
done
}
get_into_folder_function "$source_folder"
echo "Cleaning and moving completed."Here is the gist for the above script: https://gist.github.com/zoparga/93739df77d444e735c6cdf6309b3b936
Now you just need to schedule a cron job, which will check the files from time to time.