Jump to content

If You're Interested...


megaspaz
 Share

Recommended Posts

got bored and wrote a couple of bash scripts for kde 3.1.1 in redhat to delete them annoying .thumbnails directory that caches the thumbnail images of files on the hard drive.

the first file is something you would run from /etc/rc.d/rc.local and the second is if you want to run it on an individual user's account in the $HOME/.kde/Autostart directory.

 

i basically wrote this cause the cached images are .png files which over time can cause all them .thumbnails directories to get pretty big. anyway the first has the advantage in that it deletes all the .thumbnail directories in /root and all users' directories in home at one go. good if you have a lot of users, you don't have to put in the second bash script individually in each user's Autostart directory, and you want to just delete all of these directories. the drawback is if you do have a lot of users, this may impact the boot up time. of course if you don't have a lot of users, the first script is just fine. you could use the second one if you like only you in your user account care about deleting this folder, but don't care if anyone else has this directory. you'd just use the second one and put it in the $HOME/.kde/Autostart directory to run at login and let the other users of the machine go on their merry way. of course you can make the second script available to them if you want and they want to delete this .thumbnails directory too. anyway here's the code for both of them. copy and paste each section into their own text files.

 

del_thumb_boot.sh which runs at boot up using /etc/rc.d/rc.local:

#!/bin/bash

#delete hidden thumbnail folder in root

if [ -e "/root/.thumbnails" ]
then
     #loop over any subdirectories in this folder
     for sub_root in `ls /root/.thumbnails/$sub_root`
     do
          #remove all .png files in directory
          rm -f /root/.thumbnails/$sub_root/*
          #remove the current subdirectory in .thumbnails
          rmdir /root/.thumbnails/$sub_root
     done
     #remove the .thumbnails directory
     rmdir /root/.thumbnails
fi

#loop over user directories

for folders in `ls /home/`
do
     if [ -e "/home/$folders/.thumbnails" ]
     then
          #loop over any subfolders
          for sub_users in `ls /home/$folders/.thumbnails`
          do
               #remove all the .png files in directory
               rm -f /home/$folders/.thumbnails/$sub_users/*
               #remove current subdirectory in .thumbnails
               rmdir /home/$folders/.thumbnails/$sub_users
          done
          #remove the .thumbnails directory
          rmdir /home/$folders/.thumbnails
     fi
done

exit 0

Link to comment
Share on other sites

del_thumb.sh run in an individual user's $HOME/.kde/Autostart directory:

#!/bin/bash


if [ -e "$HOME/.thumbnails" ]
then
     #loop over any subfolders
     for subdirs in `ls .thumbnails`
     do
          #remove all the .png files in directory
          rm -f $HOME/.thumbnails/$subdirs/*
          #remove current subdirectory in .thumbnails
          rmdir $HOME/.thumbnails/$subdirs
     done
     #remove the .thumbnails directory
     rmdir $HOME/.thumbnails
fi

exit 0

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...