#!/usr/local/bin/perl # ####################################################################### ## chtype.pl ## 本スクリプトは、ファイルタイプを一括変換します。 ## 以下の手順でご利用ください。 ## - 下記の設定項目で、必要事項を設定します。 ## - タイプを変更したいファイルを作業状態にします。(p4 add, p4 edit) ## - perl chtype.pl を実行します。 ####################################################################### # 設定項目 $fromtype = "text"; # 変更前のタイプ (text/text\\+k/unicode/unicode\\+k) $totype = "unicode+k"; # 変更後のタイプ (text/text+k/unicode/unicode+k) $allfiles = 0; # 全クライアントのファイルの場合は 1 自分ののみは 0 ####################################################################### if( $allfiles==1 ){ $command = "p4 opened -a"; }elsif( $allfiles==0 ){ $command = "p4 opened"; }else{ die(" \$allfiles には 0 または 1 を設定してください。\n"); } open(OPENED, "$command|") || die("コマンドの実行に失敗しました。\n"); @opened = ; close(OPENED); $i = 0; while($opened[$i]) { if( $opened[$i] =~ /^(\S*)\#\d+ - \S* default change \($fromtype\)( by (\S*)@(\S*))*/) { if ($3) { $p4 = "p4 -u $3 -c $4" } else {$p4 = "p4"}; print("$p4 reopen -t $totype $1\n"); system("$p4 reopen -t $totype $1"); } elsif( $opened[$i] =~ /^(\S*)\#\d+ - \S* change \d+ \($fromtype\)( by (\S*)@(\S*))*/) { if ($3) { $p4 = "p4 -u $3 -c $4" } else {$p4 = "p4"}; print("$p4 reopen -t $totype $1\n"); system("$p4 reopen -t $totype $1"); } $i++; }