@echo off
set "src_dir=C:\Users\\Documents\projects\Config\ABC"
set OUTFILE="C:\Users\Documents\Scriptoutput.txt"
echo %OUTFILE%
pushd %cd%
cd %src_dir%
for /r %%f in (*) do (
(
<nul set /p ".= %%~dpnxf,"
certutil -hashfile "%%f" MD5 | find /V ":"
) >>%OUTFILE%
)
现在输出文件内容:
C:\Users\Documents\Projects\Config\common\abc.csv,e71073e6906e06223d184fcd91124aad
C:\Users\Documents\Projects\Config\common\def.csv,6c3f42be2f7a19a31f2002accab8273d
C:\Users\Documents\Projects\Config\common\ahi\ghi.csv,d62d1612d82eff53038ccbd4eb32a81f
C:\Users\Documents\Projects\Config\common\ahi\ert.csv,8425dbd884c27a0ba4615ef5c45b97e5
预期的:
Config\common\abc.csv,e71073e6906e06223d184fcd91124aad
Config\common\def.csv,6c3f42be2f7a19a31f2002accab8273d
Config\common\ahi\ghi.csv,d62d1612d82eff53038ccbd4eb32a81f
Config\common\ahi\ert.csv,8425dbd884c27a0ba4615ef5c45b97e5
答案1
@echo off
subst .: "%UserProfile%\Documents\Projects"
cd /d .:\ && 2>nul call del /q /f /a: ".:\Output.txt"
for /f delims^= %%i in =;(' where /r . *.* ^| find /v /i "\Output.txt" ');= do set "_path=%%~pnxi" && <nul =;(
call set /p ".=%%_path:~1%%," & certutil -hashfile "%%~fi" MD5 | find /v ":" );= >>".:\Output.txt"
type ".:\Output.txt" & cd /d "%~dp0" & subst /d .:
*.csv
或者,如果您的情况如此,请专门列出文件,或者,您也可以使用以下命令列出更多扩展:where /r . *.xlsx *.csv
:
@echo off
subst .: "%UserProfile%\Documents\Q1833755\Projects"
cd /d .:\ && 2>nul call del /q ".:\Output.txt"
for /f delims^= %%i in =;(' where /r . *.csv ');= do set "_path=%%~pnxi" && <nul =;(
call set /p ".=%%_path:~1%%," & certutil -hashfile "%%~fi" MD5 | find /v ":"
);= >>".:\Output.txt"
1.创建一个驱动器来替换你的根文件夹,例如.:
2.将其与阻止图形访问的字符关联(Windows/Explorer)
3.输入该驱动器,列出您的文件并删除变量中带有子字符串的第一个字符
4.最后,删除创建的驱动器,列出/检查您的输出
其他资源: