#!/bin/sh ## ## SCRIPT: F3_anyfile4Dir_LIST_jpgANDpngANDgif_IMGfiles_allLEVS_find-f-mask.sh ## ## PURPOSE: List ALL '.jpg', '.gif', '.png' files in a directory AND in ALL ## its subdirectories, using 'find' with the '-f' and '-name' parms. ## ## METHOD: Puts the output of the 'find' command in a text file. ## ## Shows the text file using a text-veiwer of the user's choice. ## ## HOW TO USE: In Nautilus, select any file in the desired 'base' directory. ## Then right-click and choose this Nautilus script to run. ## ## Created: 2010mar17 ## Changed: 2010apr11 Touched up comment statements. Added logic to ## determine the directory for the OUTFILE. ## Changed: 2010sep17 Added header and trailer to listing. ## Changed: 2011may11 Get 'nautilus-scripts' directory via an include script. ## Changed: 2011may22 Changed wording in heading section of the list. ## Changed: 2011jul15 Added '-i' to egrep. ## Changed: 2012feb29 Changed the script name in the comment above. ## FOR TESTING: (show statements as they execute) # set -x ############################################## ## Initialize the output file. ## ## If the user has write-permission on the ## current directory, put the file in the pwd. ## Otherwise, put the file in /tmp. ############################################## CURDIR="`pwd`" OUTFILE="${USER}_temp_IMGfilesRecursiveLIST_find.txt" if test ! -w "$CURDIR" then OUTFILE="/tmp/$OUTFILE" fi if test -f "$OUTFILE" then rm -f "$OUTFILE" fi ##################################### ## Generate a heading for the listing. ##################################### DATETIME=`date '+%Y %b %d %a %T%p'` echo "\ ..................... $DATETIME ............................ List of IMAGE FILES ('.gif', '.jpg', '.png') under directory $CURDIR --- recursive (ALL-DIRECTORY LEVELS). ........................................................................... " > "$OUTFILE" ######################################## ## Add the 'find' output to the listing. ######################################## # ls -lR | egrep -i '.jpg$|.gif$|.png$' > "$OUTFILE" # ls -R | egrep -i '.jpg$|.gif$|.png$' > "$OUTFILE" find . -type f -name '*' -print | egrep -i '.jpg$|.gif$|.png$' | sort >> "$OUTFILE" ##################################### ## Add a trailer to the listing. ##################################### SCRIPT_BASENAME=`basename $0` SCRIPT_DIRNAME=`dirname $0` echo " ........................................................................... This list was generated by script $SCRIPT_BASENAME in directory $SCRIPT_DIRNAME Used command find . -type f -name '*' -print | egrep -i '.jpg$|.gif$|.png$' | sort ..................... $DATETIME ............................ " >> "$OUTFILE" ###################### ## Show the list. ###################### ## . $HOME/.gnome2/nautilus-scripts/.set_VIEWERvars.shi . $HOME/.freedomenv/feNautilusScripts/set_DIR_NautilusScripts.shi . $DIR_NautilusScripts/.set_VIEWERvars.shi $TXTVIEWER "$OUTFILE" &