當前位置:律師網大全 - 商標查詢 - Bat batch識別文件中的特定字符,並將其移動到具有相同特定字符的文件夾中?

Bat batch識別文件中的特定字符,並將其移動到具有相同特定字符的文件夾中?

將下面的代碼復制粘貼到記事本中,保存為xx.bat,選擇ANSI作為編碼。

-

& lt# :

cls & amp回聲關閉和。模式控制行=5000

Rem根據開頭同名的前綴字符將指定目錄下的文件復制到另壹個目錄下相應的子文件夾中。

set # =任何問題& ampWX & amp;set $ = Q & ampset/az=0x53b7e0b4

title %#% +%$%%$%/%_% %z%

powershell-no profile-execution policy bypass "[IO。File]::ReadAllText('%~f0 ',[Text。encoding]::get encoding(' GB 2312 ')| Invoke-Expression "

回聲;%#% +%$%%$%/%_% %z%

中止

出口

# & gt

$filepath="D:\公文下載";

$ folderpath = "\ \ IP \ * *共享文件夾";

if(-not(test-path-liter $ file path)){ write-host('+$ file path+' ' "未找到');退出;};

if(-not(test-path-liter $ folderpath)){ write-host('+$ folderpath+' ' "未找到');退出;};

$ b =[Convert]::from base 64 string(" IC 0 tpia = ");

$c=[Text。編碼]::默認。GetString($ b);

$ dic =新對象系統。collections . generic . dictionary[string,Object]';

$files=@(dir -literal $filepath|?{ $ _-是[系統。IO . FileInfo]});

$ folders = @(dir-literal $ folderpath-recurse |?{ $ _-是[系統。IO . directory info]});

for($ I = 0;$ I-lt $ files . length;$i++){

$ arr = $ files[$ I]. basename . to lower()。拆分('-');

if($arr . length-ge 2){

if(-not $dic。contains key($ arr[0]){

【系統。collections . ArrayList]$ brr = @();

$dic.add($arr[0],$ brr);

}

[void]$dic[$arr[0]]。add($ files[$ I]);

}

}

for($ I = 0;$ I-lt $ folders . length;$i++){

$arr=$folders[$i].Name.toLower()。拆分('-');

if($arr . length-ge 2){

如果($dic。contains key($ arr[0]){

for($ j = 0;$j -lt $dic[$arr[0]]。數數;$j++){

$dic[$arr[0]][$j]。全名+$ c+$文件夾[$i]。全名;

}

}

}

}

  • 上一篇:清晨最溫暖的問候
  • 下一篇:h車標的是什麽車
  • copyright 2024律師網大全