China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 14:35
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » To output filenames without paths using the `dir` command, you can use the `/b` (bare) option. For example, `dir /b` will list only the filenames in the current directory without showing the path information. View 3,217 Replies 1
Original Poster Posted 2021-10-01 22:12 ·  中国 广东 广州 电信
新手上路
Credits 4
Posts 1
Joined 2021-09-29 22:44
4-year member
UID 184525
Gender Male
Status Offline
How to use dir to output the file names of all files in the specified directory and its subdirectories, without directory names and paths. I currently use dir /a:-d /b /s *.*>搜索.xls, but the result always retains the path. I don't need this path. I don't know how to achieve it.
Floor 2 Posted 2023-12-17 15:40 ·  中国 湖南 长沙 浏阳市 联通
新手上路
Credits 2
Posts 1
Joined 2023-05-24 21:16
3-year member
UID 184907
Gender Male
Status Offline
dir /a:-d /b /s *.* will not exclude directory names and paths unless you remove /s. If you must do recursion, you can handle it with for. for /f "delims=" %%i in ('dir /a:-d /b /s *.*') do echo,%%~nxi
Forum Jump: