情報システム科

ファイル名の変更。そのディレクトリ内のファイル名


# ファイル名の変更。そのディレクトリ内のファイル名

# 動作開始コマンド
# perl c.pl

# 置換え前の文字-----下記に文字を記入-------
$s_from="aaa";
	
# 置換え後の文字-----下記に文字を記入-------
$s_to=  "12" ;

# 対象ファイル名。全部の時は"*"-----下記に文字を記入-------
$sa="*.html";

@files=glob($sa);
foreach $file1(@files){
	if(-f $file1){
		print $file1."\n";
		# ファイル名を変更
		$file2 = $file1;
		$file2 =~ s/$s_from/$s_to/;
		print $file2."\n";			
		rename $file1,$file2;
	}
}








ホームへ