#
# *****************************************************************
# Filename: LongPathLocator.pl
# Original Author: Dick Lewis MCSE, MCT, MCP + Internet, A+
# Original Contact: [EMAIL PROTECTED]
# Original Date: 10/04/1999
# Original Purpose: This script is designed capture long paths
# inside the directory structure on a remote sharepoint
# or on a local machine. As paths reach 255 characters and beyond
# users will experience limited accessibily to there data and copy,
# edit, save and delete operations can be impacted negatively.
# The script then builds a series of HTML reports that are
# uniquely named based on the directory name.
# The length of path you want to test for is configurable
# and the reports show the actual length of the path.
# If no files are beyond the configured path threshold then the
# report is still produced but contains a line of text reporting there
# are no long paths detected.
#
# Adapted by: Urs Rau [EMAIL PROTECTED]
# New usage: To report on files which have a path length of over 64 chars
# which is a problem for the freedos booted unattended installer.
#
# First: Install ActivePerl available at [URL=http://www.activestate.com]http://www.activestate.com[/URL]
# on the computer where the script will run.
#
# CONFIG STEP #1: Enter the target directory where you want to test path length.
# Example: $Target_Directory = "\\\\Seattle\\Sales\\Reports";
#
# CONFIG STEP #2: Enter the path length threshold for testing.
# Example: $Length="200";
#
# CONFIG STEP #3: Configure the report name and location.
# $DIR must be in the report name.
# Example: $OPTFILE = "c:\\TEMP\\output$DIR.html";
#
# This script was tested using:
# ActivePerl build 519 available at [URL=http://www.activestate.com.]http://www.activestate.com.[/URL]
# Remember to use double \\back slashes
# in your path modifications below. Example: C:\\TestDir\\Fred
# or for a remote path \\\\Fileserver12\\publicshare
# Use this script carefully and test it in a
# non-production environment prior to deployment.
# *****************************************************************
#
use Getopt::Long;
use File::Basename;
# Get the time to put in the report;
$last_updated = localtime (time);
$args = @ARGV;
&GetOptions(\%options, 'dir:s', 'threshold:i', 'prefix:s', 'outdir:s', "help"
=> \$help);
if ($args < 2) {
$help = 1;
}
if ($help) {
die "usage: $0 [-h|--help show this help] -dir z:\\os\\winxppro
[-threshold 64] [-outdir c:\\temp] [-prefix winxppro]\n";
}
# CONFIG STEP #1: Enter the default target directory where you want to test path length.
# Example: $Target_Directory = $options{dir} || "\\\\Seattle\\Sales\\Reports";
$Target_Directory = $options{dir} || "d:\\docume~1";
# CONFIG STEP #2: Enter the default path length threshold for testing.
# Example: $Threshold = $options{threshold} || 200;
$Threshold = $options{threshold} || 64;
# Get the list of directories for directing
# the DIR command and naming the report. Load
# array @DirList with this data.
@DirList = `dir /AD /B $Target_Directory\\*`;
foreach $DIR ( @DirList ) {
# Chomp the $DIR variable to remove newline character.
chomp($DIR);
# Display on screen message on building file list.
print "Building list of files in $dirname directory\n\n";
# Configure the report name prefix and location here.
# CONFIG STEP #3: Report prefix
#
# Example: $OUTFILE = "prefix";
$PREFIX = $options{prefix} || "prefix";
# CONFIG STEP #4: Report directory
#
# Example: $OUTDIR = "$OUTDIR\\$PREFIX-$DIR.html";
$OUTDIR = $options{outdir} || "d:\\web\\";
# CONFIG STEP #5: Configure the report name and location here.
# $DIR must be in the report name.
# Example: $OPTFILE = "c:\\temp\\prefix-$DIR.html";
$OPTFILE = "$OUTDIR\\$PREFIX-$DIR.html";
# Display on screen message that report is being built.
print "Currently writing report to $OPTFILE\n\n";
# Open the output file.
open(OUTPUTFILE, ">$OPTFILE")|| die "open0: $!";
# Initialize the file counter with a blank value
$Counter = 0;
# Build the top of the HTML report containing
# $DIR, $last_updated and $Length variables.
# Escape out Perl reserved characters. Examples: \= and \".
print OUTPUTFILE <
Long Path Report for $dirname Folder
Last Updated: $last_updated
Path length in [red]--All paths listed over $Threshold characters.
$Counter [$Length] $File | ENDHTML } } # If the counter file has not been incremented it indicates # no long paths were detected and the message needs to be displayed. unless ($Counter) { # Print message to screen and output to file. print "No long file paths over $Threshold characters were detected in the $dirname folder.\n\n"; print OUTPUTFILE "No long file paths over $Threshold characters were detected in the $dirname folder."; } # Print the final report tags to the output file and close file. print OUTPUTFILE "