#!/usr/local/bin/perl # # ls2html.pl # # This script creates recursively index.html files in the directories, which # contain images *.gif *.jpg, so you can view all of them together # thru your favorite WWW browser... # # Run "program -h" to see the run options # # Last modified: Feb 27 1997 # Author: Bekman Stas # # Set here the pattern extensions of your image files @IMG="*.gif *.jpg"; # Usage if (($ARGV[0] ne "-r") && ($ARGV[0] ne "-s")) { print "Usage: ls2html [-hrs] -h this help -r recursive -s only in CWD\n"; exit(0); } # Create index.html only in the directory the script was called from if ($ARGV[0] eq "-s") { &index(); exit(0); } # Perl comes here only if you type "ls2html -r" &recursive(); # Subroutine "index" creates "index.html" in the current directory sub index { open(INDEX, ">index.html"); $CWD=`pwd`; print INDEX "\\n\n\\n\n\\n\n List of $CWD"; print INDEX "\n\\n\n\\n\n\\n\n"; foreach $file (<@IMG>) { print INDEX "\ $file\\n" ; } print INDEX "\n\\n\n\\n"; } # Subroutine "recursive" goes recursively down at the dir tree and # calls "index" sub. After comming to the end it's coming back up # at the tree. sub recursive { &index(); foreach $dir (<*>) { if (-d $dir) { chdir $dir; &recursive(); chdir ".."; } } }