#! /usr/bin/perl -w use strict; =head1 Notices Originally developed for Perforce by VIZIM (www.vizim.com) Copyright (c) 2014 Perforce Software, Inc. and VIZIM Worldwide, Inc. All rights reserved. Please see LICENSE.txt in top-level folder of this distribution for license information =cut use v5.14.0; # Earliest version testing was performed against my $APPNAME = 'TFSDirFormat.pl'; my $APPWHAT = 'tf dir output formatter; version 1.03'; my $APPNOTICES = "Copyright (c) 2014 Perforce Software, Inc. and VIZIM Worldwide, Inc. All rights reserved. See LICENSE.txt for license information."; =head1 tf dir output formatter Tool to convert output from the 'tf dir' command into server name format. The server name format being the format expected for the directories file supporting TFSAssociate.pl processing. Input can be from a file. However, STDIN is the more typical use as in: tf dir $/ /recursive /folders /deleted | TFSDirFormat.pl > directories =cut if( exists $ARGV[0] && $ARGV[0] =~ m!-+V! ) { print "$APPWHAT\n"; exit(0); } if( ! exists $ARGV[0] || $ARGV[0] =~ m!^\-+[h\?]! ) { print "$APPWHAT $APPNOTICES Usage: $APPNAME -V $APPNAME [-h|-?] $APPNAME tfdiroutput\n"; exit( 0 ); } if( ! -e $ARGV[0] ) { print "tf dir output file does not exist - $ARGV[0]\n"; exit 1; } my $hIn; open $hIn, '<', $ARGV[0] or die "Can't open tf dir output file $ARGV[0] - $!"; my $base = ''; while(<$hIn>) { chomp; if( m!^([^\:]+)\:$! ) { $base = $1; $base .= '/' unless $base eq '$/'; } elsif( m!^\s*$! ) { $base = ''; } elsif( $base ne '' ) { s!^\$!$base!; s!\;[XC]\d+$!!; print "D $_\n"; } else { } } close $hIn;