Last active
September 27, 2023 05:46
-
-
Save zoparga/93739df77d444e735c6cdf6309b3b936 to your computer and use it in GitHub Desktop.
Removing meta data with the help of mat2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment