I wrote a bash script for cleaning up compatdata and shadercache files for Steam games. I made it for myself and I'm only posting it here to find it later, but feel free to try/modify it yourself, if you like. Just don't blame me if it all backfires.
function steam_create_id_list()
{
IFS=$'\n'
echo "Input full path to steamapps folder:"
read pathto
compat_path="$pathto/compatdata/"
shader_path="$pathto/shadercache/"
nn=${#compat_path}
nn=$(( nn + 1 ))
results_names=()
results_id=()
array=($(ls -d $compat_path/*))
echo "" > "results.txt"
for i in "${array[@]}";do
echo $i
ID=$(echo ${i##*/})
echo $ID
ID=''$ID''
steam_api_call $ID
if [[ $NAME == "" ]];then
continue
fi
if [[ $NAME == "null" ]];then
continue
fi
results_names+=($NAME)
results_id+=($ID)
echo "$ID is $NAME"
done
echo $results
}
function steam_api_call()
{
URL="https://store.steampowered.com/api/appdetails?appids=$1";CALL="$(curl -s GET $URL)";NAME="$(echo $CALL | jq -r '.["'$1'"]["data"]["name"]')"
}
function create_list()
{
count=0
for i in "${results_names[@]}";do
echo "$count) $i"
count=$(( count + 1 ))
done
}
function dir_test_delete()
{
if [ -d "$1" ]; then
echo "deleting $1"
rm -r "$1"
fi
}
function choice_hang()
{
prompt="Select prefix to clear (or exit/list):"
echo $prompt
read choice
if [[ $choice == "exit" ]];then
exit
fi
if [[ $choice == "list" ]];then
create_list
echo "List WILL NOT update until restart"
echo $prompt
fi
if [[ $choice =~ [a-zA-Z] ]]; then
echo "numbers only"
fi
if [[ $choice =~ [0-9] ]]; then
echo "Really delete ${results_id[$choice]} (${results_names[$choice]})? <y/n>"
read choiceb
if [[ $choiceb == "y" ]];then
dir_to_delete_comp="$compat_path/${results_id[$choice]}"
dir_to_delete_shad="$shader_path/${results_id[$choice]}"
dir_test_delete $dir_to_delete_comp
dir_test_delete $dir_to_delete_shad
fi
fi
}
steam_create_id_list
create_list
c=1
while [[ $c == 1 ]];do
choice_hang
done
No comments:
Post a Comment