《修正verycd下载文件名的小程序》
电驴资源
| 用户共享的电驴资源列表 | |
|---|---|
| [cygwin.完整版.2006-09-06].cygwin-cd-release-20060906.iso | 1.28 GB |
| 1.28 GB | |
电驴资源简介
简介:
下了几个文件,结果前面全带[*****], 形如[*****].original name,烦,写个小程序自己改
本来想用perl的,结果发现perl不支持unicode,只好用c#
代码
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
namespace rename
{
class Program
{
static void Main string args
{
try
{
if args.Length = 1
{
return;
}
DirectoryInfo di = new DirectoryInfo args 0 ;
foreach FileInfo fi in di.GetFiles
{
Match ma = Regex.Match fi.Name, ^ .*? . .* ;
if ma.Success == true
{
File.Move fi.FullName,
Path.Combine fi.DirectoryName, ma.Groups 1 .Value
;
}
}
}
catch Exception
{
}
}
}
}
2进制文件等下传。
我不对该程序运行结果负责,使用前请先备份!!!
usage:
thisprogram d: yourdirectory
d: yourdirectory是你的下载文件文件夹
下了几个文件,结果前面全带[*****], 形如[*****].original name,烦,写个小程序自己改
本来想用perl的,结果发现perl不支持unicode,只好用c#
代码
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
namespace rename
{
class Program
{
static void Main string args
{
try
{
if args.Length = 1
{
return;
}
DirectoryInfo di = new DirectoryInfo args 0 ;
foreach FileInfo fi in di.GetFiles
{
Match ma = Regex.Match fi.Name, ^ .*? . .* ;
if ma.Success == true
{
File.Move fi.FullName,
Path.Combine fi.DirectoryName, ma.Groups 1 .Value
;
}
}
}
catch Exception
{
}
}
}
}
2进制文件等下传。
我不对该程序运行结果负责,使用前请先备份!!!
usage:
thisprogram d: yourdirectory
d: yourdirectory是你的下载文件文件夹
