本帖最后由 newswan 于 2021-10-6 10:55 编辑
是这个问题
%dest% 不是当前批处理文件当前路径,dir 不带/s
路径就会丢失- @echo off
-
- cd /d c:\
- echo '%%__CD__%%' %__CD__%
-
- set "dest=D:\share\tech\New folder\New folder (1)"
-
- echo,
- echo "dir /s /b"
- for /f "usebackq tokens=* delims=" %%a in (`dir /b /s "%dest%\*.txt"`) do (
- echo "%%~fa"
- )
- echo,
- echo "dir /b"
- for /f "usebackq tokens=* delims=" %%a in (`dir /b "%dest%\*.txt"`) do (
- echo "%%~fa"
- )
- pause
复制代码
|