#!/usr/local/bin/perl -w # note: rename this file to files.pl # perl script to create mappings of files # originaL url: http://www.cs.utk.edu/~maisnam/blog/archives/ # mapped (new) url: http://blog.maisnam.com/archives/ # author: bobby maisnam [ bobby AT maisnam.com ] # created: 2/28/2004 #&traverse('/home/maisnam/www-home/blog.old/blog/archives'); #current location of this file is: /home/maisnam/www-home/blog.old/blog/ #folder to traverse. relative is better. &traverse('archives'); sub traverse { local($dir) = shift; local($path); unless (opendir(DIR, $dir)) { warn "Can't open $dir\n"; closedir(DIR); return; } foreach (readdir(DIR)) { next if $_ eq '.' || $_ eq '..'; $path = "$dir/$_"; if (-d $path) { # a directory &traverse($path); } elsif (-f _) { # a plain file &create_file($path, $_); } } closedir(DIR); } sub create_file { # output directory is important. $ouputdir = "output"; #needs to be manually created $target_url = "http://blog.maisnam.com"; $filepath = $_[0]; #complete path - path also needs to be manually created. this needs a fix! #$filename = $_[1]; #filename - can be used later. # print "$filepath :: $filename\n"; $target_file = "$ouputdir/$filepath"; print "Creating file: $target_file\n"; open(FILE, ">$target_file") || die "cannot create file: $!"; print FILE ("\n"); close(FILE); }