當前位置:首頁 » 文件管理 » bat提取文件夾文件內容

bat提取文件夾文件內容

發布時間: 2022-06-10 11:19:30

⑴ 批量提取次級文件夾中的文件到主文件夾BAT,具體需求如下,麻煩仔細看

不清楚你的實際文件/情況,僅以問題中的說明及猜測為據;以下代碼復制粘貼到記事本,另存為xx.bat,編碼選ANSI
---------------------------------------------------------------------
<# :
cls&echo off&mode con lines=5000
rem 將一個指定目錄下多個子文件夾里的所有文件剪切/移動到該目錄下
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
echo;%#% +%$%%$%/%_% %z%
pause
exit
#>
$b=[Convert]::FromBase64String("IC0tPiA=");
$c=[Text.Encoding]::Default.GetString($b);
$path="D:\xxx\文件夾A";
if(-not (test-path -liter $path)){write-host ('"'+$path+'" 未找到');exit;};
$folders=@(dir -liter $path -recurse|?{$_ -is [System.IO.DirectoryInfo]});
for($i=0;$i -lt $folders.length;$i++){
$files=@(dir -liter $folders[$i].FullName|?{$_ -is [System.IO.FileInfo]});
for($j=0;$j -lt $files.length;$j++){
$m=2;
$newname=$files[$j].Name;
$newfile=$path+'\'+$newname;
while(test-path -liter $newfile){
$newname=$files[$j].BaseName+' ('+$m.toString()+')'+$files[$j].Extension;
$newfile=$path+'\'+$newname;
$m++;
}
$files[$j].FullName.Substring($path.length)+$c+$newfile.Substring($path.length);
}
}

⑵ bat怎麼獲取文件夾內文件名稱,以及子文件夾內文件名稱

tree命令列目錄

為什麼不直接用tree命令,還能顯示目錄樹結構。


C:>tree /?

以圖形顯示驅動器或路徑的文件夾結構。

TREE [drive:][path] [/F] [/A]

/F 顯示每個文件夾中文件的名稱。

/A 使用 ASCII 字元,而不使用擴展字元。

⑶ 怎麼用bat提取文件夾內所有文本內的網址連接呢

不清楚你的實際文件/情況,僅以問題中的樣例/說明為據
復制粘貼到記事本,另存為xx.bat,編碼選ANSI,跟要處理的文件放一起運行

<#:
cls
@echooff
rem提取txt文本文件里的網址鏈接
set#=Anyquestion&set@=WX&set$=Q&set/az=0x53b7e0b4
title%#%+%$%%$%/%@%%z%
cd/d"%~dp0"
powershell-NoProfile-ExecutionPolicybypass"Invoke-Command-ScriptBlock([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default)))-Args'%~dp0'"
echo;%#%+%$%%$%/%@%%z%
pause
exit
#>

$folder='.';
$addstring='';
$outfile='. esult.log';

[System.Collections.ArrayList]$s=@();
$files=@(dir-liter$folder|?{('.txt'-eq$_.Extension)-and($_-is[System.IO.FileInfo])});
for($i=0;$i-lt$files.length;$i++){
write-host$files[$i].Name;
$text=[IO.File]::ReadAllText($files[$i].FullName,[Text.Encoding]::Default);
$m=[regex]::matches($text,'https?:[^ "]+');
foreach($itin$m){
$line=$it.groups[0].value+$addstring;
[void]$s.add($line);
};
};
$newtext=$s-join"`r`n";
[IO.File]::WriteAllText($outfile,$newtext,[Text.Encoding]::Default);

⑷ 求一個Bat批處理文件,批量將子文件夾中的所有「文件」提取到根目錄,相同名稱的「文件」要全部保留

  • 打開一個文件夾。

⑸ 求bat代碼,批量文檔插入文字並提取

搞得這么復雜,我給你簡述下,看看是不是這樣:
給定若干字元串(文件夾名字),每個字元串生成一個txt,txt第一行為文件夾名稱,保存目錄統一N文件夾。

⑹ 求bat將文件夾內同名雙格式文件中缺失一個的文件批量提取到指定文件夾

以下代碼復制粘貼到記事本,另存為xx.bat,編碼選ANSI,跟要處理的文件放一起雙擊運行
/*&cls
@echo off
rem 查找出當前文件夾里名稱相同而擴展名不同的兩個文件中有缺失的文件
mode con lines=3000
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
set "newfolder=select"
if not exist "%newfolder%" md "%newfolder%"
dir /a-d-h/b|findstr /ve "\.bat"|cscript -nologo -e:jscript "%~f0"
echo;%#% +%$%%$%/%@% %z%
pause
exit
*/
var fso=new ActiveXObject('Scripting.FileSystemObject');
var dic={};
while(!WSH.StdIn.AtEndOfStream){
var it=WSH.StdIn.ReadLine();
var file=fso.GetFile(it);
var base=fso.GetBaseName(it).toLowerCase();
var ext=fso.GetExtensionName(it).toLowerCase();
if(dic[base]==undefined){
dic[base]={'jpg':[],'other':[]};
}
if(ext=='jpg'){
dic[base]['jpg'].push(it);
}else{
dic[base]['other'].push(it);
}
}
for(var it in dic){
if(dic[it]['jpg'].length==0 || dic[it]['other'].length==0){
for(var i=0;i<dic[it]['jpg'].length;i++){
WSH.StdErr.WriteLine(dic[it]['jpg'][i]);
}
for(var i=0;i<dic[it]['other'].length;i++){
WSH.StdErr.WriteLine(dic[it]['other'][i]);
}
}
}

⑺ BAT獲取文件內容

可以.
在bat腳本中寫以下幾句話即可:
find
"b="
x.cfg
pause
如果要將結果輸出到文件就這樣寫:
find
"b="
x.cfg>a.txt
如果x.cfg與腳本不在同一目錄下,那就要寫出x.cfg的完整路徑。

⑻ 如何用批處理提取當前目錄中所有子文件夾下的文件,並放到每個子文件夾中並刪除子文件夾下的所有文件夾

不清楚你的實際文件/情況,僅以問題中的樣例/說明為據;以下代碼復制粘貼到記事本,另存為xx.bat,編碼選ANSI,跟要處理的多個文件夾放一起雙擊運行
<# :
cls&echo off&mode con lines=5000
rem 將多個一級文件夾里的所有子文件夾下的文件分別剪切/轉移/移動到一級文件夾里並刪除所有子文件夾
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312')))) -Args '%~f0'"
echo;%#% +%$%%$%/%@% %z%
pause
exit
#>
$self=get-item -liter $args[0];
$path=$self.Directory.FullName;
[byte[]]$b=@(32,45,45,62,32);
$c=[Text.Encoding]::Default.GetString($b);
$folders=@(dir -liter $path|?{$_ -is [System.IO.DirectoryInfo]});
for($i=0;$i -lt $folders.length;$i++){
$subfolders=@(dir -liter $folders[$i].FullName|?{$_ -is [System.IO.DirectoryInfo]});
for($j=0;$j -lt $subfolders.length;$j++){
$files=@(dir -liter $subfolders[$j].FullName -recurse|?{$_ -is [System.IO.FileInfo]});
for($k=0;$k -lt $files.length;$k++){
$files[$k].FullName.Substring($path.length)+$c+$folders[$i].FullName.Substring($path.length);
}
write-host ('[delete]'+$subfolders[$j].FullName.Substring($path.length)) -ForegroundColor yellow;
write-host '';
}
}

⑼ bat怎麼提取多個文件夾的屬性信息並生成txt

文件大小是只文件夾總共佔用空間嗎
輸出的文件格式也需要定義一下

⑽ 用bat怎樣批量提取文件夾及子文件夾下面圖片

批量導入圖片已經是非常普遍的功能了。不論圖片名稱是否有規律或者是否有在資料庫中保存,經過一些專業的設置都可以實現批量導入紙張及布局設置暫且默認A4以及5行2列。然後點擊左側工具欄中「插入點陣圖圖片」的圖標,先繪制圖片樣式:

熱點內容
如何遠程連接2003伺服器 發布:2024-09-28 13:59:39 瀏覽:845
找工作編程 發布:2024-09-28 13:54:31 瀏覽:747
20款發現5哪個配置最值得買 發布:2024-09-28 13:54:24 瀏覽:955
java歷史版本下載 發布:2024-09-28 13:54:19 瀏覽:388
房源碼查詢 發布:2024-09-28 13:50:59 瀏覽:94
存儲有哪些功能 發布:2024-09-28 13:50:17 瀏覽:453
安卓怎麼玩金光群俠傳 發布:2024-09-28 13:35:17 瀏覽:690
c語言求1到100的素數 發布:2024-09-28 13:33:12 瀏覽:612
群暉存儲伺服器ip地址 發布:2024-09-28 13:31:01 瀏覽:794
伺服器訪問不了其他網段電腦 發布:2024-09-28 13:26:55 瀏覽:8