
求助批處理分類文件管理該怎么弄
- @echo off
- rem 根據從文件名中指定字符串/關鍵詞開始截取指定位數的字符來移動文件到對應文件夾
- cd /d %~dp0
- set keyword=板件料單
- set n=4
- powershell -NoProfile -ExecutionPolicy bypass ^
- $files=@(dir^|?{($_ -is [System.IO.FileInfo]) -and ($_.Name -ne '%~nx0')});^
- for($i=0;$i -lt $files.length;$i++){^
- $n=$files[$i].baseName.IndexOf('%keyword%');^
- if($n -ge 0){^
- $s=$files[$i].baseName.Substring($n);^
- if($s.length -ge %n%){^
- $kw=$s.Substring(0,%n%);^
- [void](md $kw -force);^
- $txt=$files[$i].Directory.FullName+''+$kw+'%n%.txt';^
- out-file -file $txt -input $kw -enc Default;^
- write-host ($files[$i].Name+' --^> '+$kw);^
- mv -liter $files[$i].FullName ($files[$i].Directory.FullName+''+$kw);^
- };^
- };^
- }
- set keyword=報價單
- set n=3
- powershell -NoProfile -ExecutionPolicy bypass ^
- $files=@(dir^|?{($_ -is [System.IO.FileInfo]) -and ($_.Name -ne '%~nx0')});^
- for($i=0;$i -lt $files.length;$i++){^
- $n=$files[$i].baseName.IndexOf('%keyword%');^
- if($n -ge 0){^
- $s=$files[$i].baseName.Substring($n);^
- if($s.length -ge %n%){^
- $kw=$s.Substring(0,%n%);^
- [void](md $kw -force);^
- $txt=$files[$i].Directory.FullName+''+$kw+'%n%.txt';^
- out-file -file $txt -input $kw -enc Default;^
- write-host ($files[$i].Name+' --^> '+$kw);^
- mv -liter $files[$i].FullName ($files[$i].Directory.FullName+''+$kw);^
- };^
- };^
- }
- set keyword=配件料單
- set n=4
- powershell -NoProfile -ExecutionPolicy bypass ^
- $files=@(dir^|?{($_ -is [System.IO.FileInfo]) -and ($_.Name -ne '%~nx0')});^
- for($i=0;$i -lt $files.length;$i++){^
- $n=$files[$i].baseName.IndexOf('%keyword%');^
- if($n -ge 0){^
- $s=$files[$i].baseName.Substring($n);^
- if($s.length -ge %n%){^
- $kw=$s.Substring(0,%n%);^
- [void](md $kw -force);^
- $txt=$files[$i].Directory.FullName+''+$kw+'%n%.txt';^
- out-file -file $txt -input $kw -enc Default;^
- write-host ($files[$i].Name+' --^> '+$kw);^
- mv -liter $files[$i].FullName ($files[$i].Directory.FullName+''+$kw);^
- };^
- };^
- }
- del /a /s /q *.txt
- del /a /s /q *.xml
- cd /d %~dp0
- set newfolder=模型
- if not exist %newfolder% md %newfolder%
- for %%a in (bmp) do (
- if exist *.%%a move /y *.%%a %newfolder%
- )
- set newfolder=模型
- if not exist %newfolder% md %newfolder%
- for %%a in (bmp) do (
- if exist *.%%a move /y *.%%a %newfolder%
- )
- echo;移動已完成!
nclick="copycode($('code0'));">復制代碼
這是現在在用的代碼,目前遇到了一個新的問題 ,生成的文件里面有一些是包含MY、BL、等等之類的 需要單獨建立一個文件夾把他們放進去,這一塊不知道該怎么添加了求助各位大佬