Skip to content

Instantly share code, notes, and snippets.

@quaxsze
Created July 15, 2020 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quaxsze/dc089e4ecd2e00f82acea573d8d2cfb9 to your computer and use it in GitHub Desktop.
Save quaxsze/dc089e4ecd2e00f82acea573d8d2cfb9 to your computer and use it in GitHub Desktop.
#!/bin/bash
resources_path="instance/fs/resources"
avatars_path="instance/fs/avatars"
images_path="instance/fs/images"
echo "Processing resources"
resources_counter=0
for f in $(find "$resources_path")
do
if [ -f $f ]
then
foo=${f#"$resources_path/"}
if ! grep -Fxq "$foo" resource_fs.txt
then
echo $f >> resources_deletion.txt
rm $f
(( resources_counter++ ))
fi
fi
done
echo "Resources completed"
echo "Resources deletion: ${resources_counter}"
echo "Processing avatars"
avatars_counter=0
for f in $(find "$avatars_path")
do
if [ -f $f ]
then
match=0
while read p
do
if [[ $f == *$p* ]]
then
match=1
break
fi
done < avatar_fs.txt
if [ $match -eq 0 ]
then
echo $f >> avatars_deletion.txt
rm $f
(( avatars_counter++ ))
fi
fi
done
echo "Avatars completed"
echo "Avatars deletion: ${avatars_counter}"
echo "Processing images"
images_counter=0
for f in $(find "$images_path")
do
if [ -f $f ]
then
match=0
while read p
do
if [[ $f == *$p* ]]
then
match=1
break
fi
done < image_fs.txt
if [ $match -eq 0 ]
then
echo $f >> images_deletion.txt
rm $f
(( images_counter++ ))
fi
fi
done
echo "Images completed"
echo "Images deletion: ${images_counter}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment