#!/bin/sh ## ## SCRIPT: htm00_multi-img-files_small-img-TableCELLS_NperRow_echo_for-loop.sh ## ## PURPOSE: Generate an HTML file showing small (less than 160 pixels high/wide) ## image files IN ROWS down the page --- in table rows, N cells per row ## --- using the selected image files ('.jpg' , '.gif' or whatever). ## ## METHOD: Uses 'zenity --entry' to prompt for N (the number of cells per row). ## ## Uses 'echo' to generate the lines of the HTML file. ## ## This script shows the HTML file in an html-viewer of the user's choice ## ($HTMLVIEWER), and puts the user in edit mode on the HTML file ## using a text-editor of the user's choice ($TEXTEDITOR). ## ## HOW TO USE: In Nautilus, select one or more image files in a directory. ## Then right-click and select this script to run (name above). ## ## This script puts the '.htm' HTML file in the directory ## with the image files. ## ############################################################################# ## Started: 2011nov21 Based on 00_GENpage_thumbTableCells_SELimgFiles_NperRow.sh ## Changed: 2012may14 Changed script name in comments above and touched up ## the comments. Changed some indenting below. ########################################################################### ## FOR TESTING: (show statements as they execute) # set -x ################################################## ## Set the HTMLVIEWER and TXTEDITOR env vars. ################################################## ## . $HOME/.gnome2/nautilus-scripts/.set_VIEWERvars.shi . $HOME/.freedomenv/feNautilusScripts/set_DIR_NautilusScripts.shi . $DIR_NautilusScripts/.set_VIEWERvars.shi ################################################## ## Get N, the number of image-cells per row. ################################################## CELLSperROW="" CELLSperROW=$(zenity --entry \ --title "N - number of image-cells per row" \ --text "\ ENTER the desired NUMBER of image-cells PER ROW : Typically use 4, 5, or 6 --- depending on the 'small' image sizes. A '.htm' file will be created in the current directory --- and it will be shown in an HTMLVIEWER: $HTMLVIEWER and it will be shown in a TXTEDITOR: $TXTEDITOR" \ --entry-text "6") if test "$CELLSperROW" = "" then exit fi ################################### ## Set the HTML output file name. ################################### HTMFILE="00_temp_imgTableCells_smallImages_${CELLSperROW}perRow.htm" if test -f "$HTMFILE" then rm "$HTMFILE" fi ##################################################### ## Put the (skeleton) 'head', 'title', and 'intro' ## sections in the HTML file. ##################################################### echo " Title Goes Here

Title Goes Here

subtitle goes here

To download an image, you can right-click on an image and use an option like 'Save Image As ...' in the popup menu of your web browser.

" > "$HTMFILE" ######################################### ## START THE LOOP on the filenames. ######################################### FILECNT=0 ROWCNT=0 for FILENAME do FILECNT=`expr $FILECNT + 1` ROWID=" " #################################################################### ## IF AT START of ROW, set ROWCNT and ROWID and ## write start-of-row HTML indicators (row-number-comment and ). #################################################################### if test `expr $FILECNT % $CELLSperROW` = 1 then ROWCNT=`expr $ROWCNT + 1` ROWID="row $ROWCNT" echo " " >> "$HTMFILE" fi ###################################################### ## Crop suffix (like '.jpg' or '.gif') from filename, ## for use in naming the '_thumb.jpg' files. ## (Assumes only one dot, at extension in filename.) ###################################################### # FILENAMECROP=`echo "$FILENAME" | sed 's|\.jpg$||'` # FILENAMECROP=`echo "$FILENAME" | sed 's|\.jpg$||' | sed 's|\.gif$||'` # FILENAMECROP=`echo "$FILENAME" | sed 's|\..*$||'` ################################### ## Write out table cell definition. ################################### echo " " >> "$HTMFILE" ############################################################### ## IF exactly AT END OF ROW, write out table-row-end indicator. ############################################################### if test `expr $FILECNT % $CELLSperROW` = 0 then echo " " >> "$HTMFILE" fi done ######################################################## ######################################################## ## END OF FILES LOOP. Write out bottom of the HTML file. ######################################################## ######################################################## ################################################ ## Write out remaining cells (empty, if any) ## in the last row. ################################################ if test `expr $FILECNT % $CELLSperROW` != 0 then while test `expr $FILECNT % $CELLSperROW` != 0 do echo " " >> "$HTMFILE" FILECNT=`expr $FILECNT + 1` done echo " " >> "$HTMFILE" fi ################################################### ## After writing out remaining cells (empty, if any) ## in the last row, write the bottom-of-page block. ################################################### echo "

$ROWID
 
 

Bottom of the Title Goes Here page.

To return to a previously visited web page location, click on the
Back button of your web browser, a sufficient number of times.
OR, use the History-list option of your web browser.
OR ...

< Go to Start of Images, above. >
< Go to Top of Page, above. >

Page created 2010 xxx 00.

" >> "$HTMFILE" ################################### ## SHOW HTML FILE in a web browser. ################################### $HTMLVIEWER "$HTMFILE" & ################################## ## Put HTML FILE in a text editor. ################################## $TXTEDITOR "$HTMFILE"