rename批量改名的perl脚本
发布时间:2020-12-15 21:06:29 所属栏目:大数据 来源:网络整理
导读:########################2010. jordan.sg #use strict;use File::Find;use Cwd;my $path = getcwd();open(LOG,"error.log") or die "open log file fail!";print LOG "n";#my $object_count = 0;sub wanted {#print "wanted $File::Find::namen"; if ( -f
########################2010. jordan.sg # use strict; use File::Find; use Cwd; my $path = getcwd(); open(LOG,">error.log") or die "open log file fail!"; print LOG "n"; #my $object_count = 0; sub wanted { #print "wanted $File::Find::namen"; if ( -f $File::Find::name ) { if ( $File::Find::name =~ /t.txt$/ ) { print LOG "$File::Find::namen"; my $srcfile= $File::Find::name; my $file = $_; print LOG "- $_n"; $file =~ s/t.txt//; print LOG "> $filen"; rename($srcfile,$file); } } #$obj_count++; } find( &;wanted,$path ); #print LOG "rename $obj_count filesn"; ##打印处理文件数 close(LOG); #$File::Find::dir :当前路径名 #$_ :当前文件名不包含路径 #$File::Find::name :全路径的当前文件名 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |