Inital commit

This commit is contained in:
Tobias Herre 2023-10-24 19:20:23 +02:00
parent 8b54824842
commit a362bc106a
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
#!/bin/bash
# Path to the folder containing files
folder_path="$1"
# Path to the file containing the list of filenames
list_file="$2"
# Check if the folder exists
if [ ! -d "$folder_path" ]; then
echo "Folder does not exist: $folder_path"
exit 1
fi
# Check if the list file exists
if [ ! -f "$list_file" ]; then
echo "List file does not exist: $list_file"
exit 1
fi
# Loop through the files in the folder
for file_in_folder in "$folder_path"/*; do
# Check if the current file is a regular file
if [ -f "$file_in_folder" ]; then
# Get the filename without the path
filename=$(basename "$file_in_folder")
# Check if the filename is not in the list
if ! grep -qFx "$filename" "$list_file"; then
echo "Deleting: $file_in_folder"
rm "$file_in_folder"
fi
fi
done