source: trunk/gsdl/bin/script/convert_toc_dir.pl@ 3081

Last change on this file since 3081 was 3081, checked in by sjboddie, 22 years ago

* empty log message *

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 875 bytes
Line 
1#! /usr/bin/perl -w
2
3# run convert_toc.pl on any html files found in the directory passed in on
4# the command line (or any subdirs).
5
6die "\$GSDLOS not set !\n" if (!defined $ENV{GSDLOS});
7my ($move, $separator);
8if ($ENV{GSDLOS} eq "windows") {
9 $move = "move";
10 $separator = "\\";
11} else {
12 $move = "mv";
13 $separator = "/";
14}
15
16&recurse($ARGV[0]);
17
18sub recurse {
19 my ($dir) = @_;
20
21 if (!-d $dir) {
22 print STDERR "ERROR: $dir isn't a directory\n";
23 return;
24 }
25
26 opendir (DIR, $dir) || die;
27 my @files = readdir DIR;
28 closedir DIR;
29
30 foreach my $file (@files) {
31 next if $file =~ /^\.\.?$/;
32 my $fullpath = "$dir$separator$file";
33 if (-d $fullpath) {
34 &recurse($fullpath);
35 } elsif ($file =~ /\.html?$/i) {
36 print STDERR "converting $fullpath\n";
37 `convert_toc.pl $fullpath $fullpath.new`;
38 `$move $fullpath.new $fullpath`;
39 }
40 }
41}
Note: See TracBrowser for help on using the repository browser.