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-08-13 00:39
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to get the names of all files and folders in the current path View 1,607 Replies 4
Original Poster Posted 2009-11-29 01:05 ·  中国 天津 电信
初级用户
★★
Credits 128
Posts 122
Joined 2009-09-21 06:24
16-year member
UID 152378
Gender Male
Status Offline
As the title says, how to get the names of all files and folders in the current path and assign these names to variables one by one?
Floor 2 Posted 2009-12-01 13:20 ·  中国 天津 电信
初级用户
★★
Credits 128
Posts 122
Joined 2009-09-21 06:24
16-year member
UID 152378
Gender Male
Status Offline
I'm a newbie. Is this question too simple so that it's boring to answer? Then please give me a hint and train of thought, please!
Floor 3 Posted 2009-12-01 14:10 ·  中国 北京 阿里云BGP服务器
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Is this???
@echo off
setlocal enabledelayedexpansion
set n=0
for /f "delims=" %%a in ('dir /b /a *') do (
set /a n+=1
set name!n!="%%a"
)
for /l %%a in (1 1 !n!) do (
echo.!name%%a!
)
pause
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
jarry0932 +2 2009-12-04 16:53
Floor 4 Posted 2009-12-04 16:52 ·  中国 天津 电信
初级用户
★★
Credits 128
Posts 122
Joined 2009-09-21 06:24
16-year member
UID 152378
Gender Male
Status Offline
That's exactly it. Thanks for the code from the user above.
Floor 5 Posted 2009-12-11 17:09 ·  中国 山东 青岛 联通
新手上路
Credits 14
Posts 10
Joined 2009-12-01 21:49
16-year member
UID 155758
Gender Male
Status Offline
Thanks, I've also studied
Forum Jump: