Folder find the name of the folder inside the directory

I have a question about batch files

So, inside this one directory, let's say C: \ temp \ I have two elements: one is a folder, and the other is a text file called "list.txt"

How can I find the folder name?

thank

+5
source share
2 answers

If you want to simply specify subdirectories of the current directory:

dir /ad /b

If you are in a different directory, you can simply do:

dir c:\temp /ad /b

/admeans a list of all elements with the attribute "catalog", and /b- this is a bare format

Update:

, , dir cmd . , , , "". , (/on) MY_ENV_VAR :

for /f "delims=" %%a in ('dir "c:\temp" /on /ad /b') do @set MY_ENV_VAR=%%a

, script , PowerShell, .

Get-ChildItem | where {$_.PSIsContainer}

, .

+3

:

for /d /r "C:\temp" %%i in (*.*) do echo %%~i
+2

All Articles