当我们在下载时候,一般都有一个默认的文件夹,因为指定目录比较麻烦,而且也不方便,一般都使用了默认目录。但长久下去默认目录就比较复杂,所以得对其进行管理。
下面是我写的将音乐下载文件夹的文件转移到我的音乐文件夹的一段代码,很简单,当然稍微修改也可以管理其他文件,只要修改后缀就可以了
下面是我写的将音乐下载文件夹的文件转移到我的音乐文件夹的一段代码,很简单,当然稍微修改也可以管理其他文件,只要修改后缀就可以了
- #!/usr/bin/perl -w
- use strict;
- my $root = "C://My data//music";
- my $target = "C://KuGou";
- opendir KUGOO,$target or die "can not find kugoo $!/n";
- my @fileList = grep(!/^/./.?$/,readdir KUGOO);
- closedir KUGOO;
- foreach my $file (@fileList){
- chdir $target or die "fail to execute,$!/n";
- if ($file =~ //.(txt|mp3|wma)$/i){
- my $path = $target."//".$file;
- my $command = "copy /Y ".'"'.$path.'" '.'"'.$root.'"';
- print $command,"/n";
- `$command`;
- }
- }
- foreach my $file(@fileList){
- my $path = $target."//".$file;
- unlink $path;
- }
本文介绍了一个简单的Perl脚本,用于将默认下载目录中的音乐文件(如mp3、wma等格式)批量移动到个人音乐文件夹中,并删除源文件夹中的已转移文件。这个实用的脚本有助于整理杂乱的下载目录。
2011

被折叠的 条评论
为什么被折叠?



