[日常]bilibili blv视频文件转移到同一目录并编号

There's more than one way to do it!
https://metacpan.org http://perlmonks.org
回复
头像
523066680
Administrator
Administrator
帖子: 573
注册时间: 2016年07月19日 12:14
联系:

[日常]bilibili blv视频文件转移到同一目录并编号

帖子 523066680 »

个人用途~
=info 将 Bilibili Download 目录下的 blv 文件收集 修改为 flv 格式 (这个目录是从手机复制到PC的) 2019-05 =cut use Modern::Perl; use File::Basename; use File::Path; use File::Copy; use Cwd; STDOUT->autoflush(1); my $wdir = "collect"; my @files = `dir /s /b *.blv`; my $cwd = getdcwd; mkpath $wdir unless -d $wdir; grep { s/\r?\n$//; s/^\Q$cwd\E\\// } @files; print join("\n", @files); my %hash; for my $p ( @files ) { my ($head) = split(/\\/, $p); next if $head eq $wdir; if ( exists $hash{$head} ) { $hash{$head} +=1; } else { $hash{$head} = 1; } my $fname = sprintf "%s_%02d%s", $head, $hash{$head}, ".flv"; copy( $p, $wdir . "/" . $fname ); }
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客