我可以使用下面的代码获取所有文件名,路径大小等的列表,但我无法消除文件名和文件路径中的双引号。我在文件名中也有空格,当列出文件名时该空格会中断。
@echo off
setlocal enabledelayedexpansion
if exist Z:\ (net use Z: /delete)
net use Z: "\\my drive path"
SET Path1=Z:\
pushd
SET "Path2=Z:\folder1"
for /f "skip=1 tokens=1,2,3,4,5* delims=,] " %%i in ('forfiles /p "%Path2%" /s /m ""*.mmp"" /c "cmd /c echo @fsize 0x22@file0x22 @path @fdate @ftime"') do (
set FILE_SIZE_WINDOWS=%%i
set FILE_NAME=%%~j
set FILE_PATH=%%~k
set FILE_DATE=%%l
set FILE_TIME=%%m
set "unit=B"
for %%b in (KB MB GB TB PB EB ZB YB) do if 1024 lss !FILE_SIZE_WINDOWS! (
set "unit=%%b"
if !FILE_SIZE_WINDOWS! lss 2147483647 (set /a "FILE_SIZE_WINDOWS=FILE_SIZE_WINDOWS/1024") else (set "FILE_SIZE_WINDOWS=!FILE_SIZE_WINDOWS:~0,-3!"))
if "!FILE_NAME!" neq "!FILE_NAME:Admin=!" (set Developer=Admin
echo !Developer!)
echo !FILE_NAME! !FILE_SIZE_WINDOWS!!unit! !FILE_PATH! !FILE_DATE! !FILE_TIME! !Developer!
if "!FILE_NAME!" == "!FILE_NAME:Undo=!" (echo !FILE_NAME! does not contain Undo
echo !FILE_NAME! !FILE_SIZE_WINDOWS!!unit! !FILE_PATH! !FILE_DATE! !FILE_TIME! !Developer! >> List.txt
) else (
echo !FILE_NAME! !FILE_SIZE_WINDOWS!!unit! !FILE_PATH! !FILE_DATE! !FILE_TIME! !Developer! >> UndoList2.txt
)
)
echo Done
popd
endlocal
Expected output:
Filename.mmp C:\Filepath