以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI
@echo off
rem 获取指定目录下的所有文件路径并进行截取
set #=Any question&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$% %z%
cd /d "%~dp0"
set "folder=D:\xxx\A"
set "outfile=xxx.txt"
type nul>"%outfile%"
if not exist "%folder%" (echo;"%folder%" not found&goto end)
for /f "delims=" %%a in ("%folder%") do set "fd=%%~nxa"
for /f "delims=" %%a in ('dir /a-d/b/s "%folder%\"') do (
set "fpath=%%a"
setlocal enabledelayedexpansion
>>"%outfile%" echo;%fd%!fpath:%folder%=!
endlocal
)
:end
echo;%#% +%$%%$% %z%
pause
@echo off
rem 获取指定目录下的所有文件路径并进行截取
set #=Any question&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$% %z%
cd /d "%~
dp0
"
set "源目录=D:\xxx\A"
set "输出=xxx.txt"
type nul>"%输出%"
for /f "delims=" %%a in ("%源目录%") do set "fd=%%~nxa"
for /f "delims=" %%a in ('dir /a-d/b/s "%源目录%"') do (
set "fpath=%%a"
setlocal enabledelayedexpansion
>>"%输出%" echo;%fd%!fpath:%源目录%=!
endlocal
)
echo;%#% +%$%%$% %z%
pause
很简单:
dir /s /b>1.txt
然后在1.txt里,把你不需要的 d:/C 替换为空即可。