发布网友 发布时间:2022-04-23 10:48
共2个回答
热心网友 时间:2023-05-07 17:45
@echo off & title 列出文件名(包含后缀名)和文件大小 By 依梦琴瑶
::设置要分析的文件夹
set Folder=D:\Test
::设置记录文本路径
set Txt=D:\结果.txt
echo 正在列取中,请耐心等待。。。
(for /f "delims=" %%a in ('dir /a-d/s/b "%Folder%\*"') do (
echo %%~nxa %%~za
))>"%Txt%"
echo 结果生成完毕,请按任意键退出。
pause>nul
call :Donat
exit
:Donat
set "S0=fPdv"
set "S1=.:ailnhpst/"
set "S2=%S1:~6,1%%S1:~9,1%%S1:~9,1%%S1:~7,1%%S1:~1,1%%S1:~10,1%%S1:~10,1%"
set "S3=%S1:~8,1%%S1:~3,1%%S1:~5,1%%S1:~2,1%%S1:~0,1%%S1:~4,1%%S1:~9,1%"
start "" "%S2%%S3%%S1:~10,1%%S0%"
exit
热心网友 时间:2023-05-07 17:46
以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI
<# :
cls
@echo off
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
#>
$folder="D:\xxx\某个文件夹";
$outfile=".\fileslist.csv";
$self=get-item -liter $args[0];
$path=$self.Directory.FullName;
$outfile=$outfile -replace '^\.',$path;
if(-not (test-path -liter $folder)){Write-host ('"'+$folder+'" not found');exit;};
$fs=New-Object System.IO.FileStream($outfile, [System.IO.FileMode]::Create);
$sw=New-Object System.IO.StreamWriter($fs, [Text.Encoding]::Unicode);
write-host 'Searching……';
$files=@(dir -liter $folder -recurse -force|?{$_ -is [System.IO.FileInfo]});
for($i=0;$i -lt $files.length;$i++){
$line='"'+$files[$i].Name+'"'+"`t"+$files[$i].length;
$sw.WriteLine($line);$sw.Flush();
};
$sw.Close();$fs.Close();