#! /usr/bin/perl # # NAME: filesize.pl # DESC: Displays the output of the 'p4 fstat -Ol' command showing the depot path # and 'fileSize' field with file length in bytes. # # P4V Custom Tool Setup: ## Name: Show Dir File Sizes ## Application: /home/user/customtools/filesize.pl ## Arguments: %D $u $p ## Check-box: Add to Applicable Context Menus ## Check-box: Run tool in terminal window # $path = shift ARGV; #The depot spec to search in. $user = shift ARGV; #The current user. $server = shift ARGV; #ip_address:port of your Perforce server. $p4 = "p4"; #Absolute path to the p4 cli program. if (($path eq "//depot/...") or ($path eq "//...")) { print "Path too broad. Select a subdirectory and try again.\n"; exit 1; } $cmd = "\"$p4\" -u $user -p $server fstat -Ol \"$path\" | grep '\^\.\.\. fileSize\\\|^\.\.\. depotFile' 2>&1 |"; open RESULTS, $cmd or die "Cannot run filesize command.\n\n"; $filespace; $count = 0; while () { chomp; if(/^filespace/) { $filespace = $_; } print "...\n"; print "$_\n"; $count++; } if($count ne 0) { print "\nFile size information completed.\n"; } if($count eq 0) { print "\nNo results found.\n"; } exit 0;