#!/bin/bash # # Create soft links with appropriate file extentions for some of the # graphic files in Netscape cache, then fire up a viewer to browse then. # # 01/10/2003 For Slackware 8.1.01 / Netscape 7.0.1 # # We'll pick the 'n' largest / newest files # NS_CACHE=/home/username/.mozilla/default/directory/Cache MAX_FILES=300 TMPFILE1=/tmp/tmp1_.tmp TMPFILE2=/tmp/tmp2_.tmp DIRROOT=/tmp DIRNAME=tmp_dir1 VIEWER=gqview cd $NS_CACHE # Get filenames, sizes, and binary timestamps, omitting # the '_CACHE_MAP_' file and friends; sorted by size and timestamp. find . \ -type f \ ! -name "_*" \ -printf "%P %s %T@\n" | sort -k 2,2nr -k3,3 >$TMPFILE1 # Strip just the filenames for 'file' gawk '{ print $1 }' $TMPFILE1 >$TMPFILE2 # Get the filetypes file -z -f $TMPFILE2 >$TMPFILE1 # pick out the image files, and output filenames and extensions gawk -v max_files=$MAX_FILES ' \ /image data/ \ { if (files_out >= max_files) exit 0; fn = substr($1,1,length($1)-1); if ($2 == "JPEG") { files_out++; printf "%s file%03d.jpeg ", fn, files_out; } else if ($2 == "GIF") { files_out++; printf "%s file%03d.gif ", fn, files_out; } else if ($2 == "PNG") { files_out++; printf "%s file%03d.png ", fn, files_out; } } END { if (files_out < 1) exit 1; else exit 0; } ' $TMPFILE1 >$TMPFILE2 if [ $? -ne 0 ] ; then echo "Nothing to display." exit 0 fi # Now we read the list into a shell variable LIST=`cat $TMPFILE2` # Make a clean subdirectory and create the links cd $DIRROOT rm -f -r $DIRNAME mkdir $DIRNAME cd $DIRNAME F="" for I in $LIST ; do if [ -z $F ] ; then F=$I else ln -s $NS_CACHE/$F $I touch -r $NS_CACHE/$F $I F="" fi done $VIEWER . rm -f $TMPFILE1 $TMPFILE2 rm -f -r $DIRROOT/$DIRNAME