The Computer Oracle

how to list all files and directories in given directory with full path but not recursive?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Magical Minnie Puzzles

--

Chapters
00:00 How To List All Files And Directories In Given Directory With Full Path But Not Recursive?
00:35 Answer 1 Score 1
00:55 Answer 2 Score 0
01:19 Accepted Answer Score 11
01:35 Answer 4 Score 18
01:46 Thank you

--

Full question
https://superuser.com/questions/417254/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows #windowsxp #commandline #ls #dir

#avk47



ANSWER 1

Score 18


Try the following command:

dir /s /b /a

It will give ALL files, you can run it through FIND if you want or add a folder name.




ACCEPTED ANSWER

Score 11


If you don't want to install anything, you could also use the following command:

for /f "delims=" %a in ('cd') do @for /f %b in ('dir /b /a') do @echo %a\%b

You have to cd into the directory first or it won't work.




ANSWER 3

Score 1


If you tried ls, why not just install cygwin? You can use find in cygwin:

find -name "*"

If you do install cygwin and want to use find in cygwin, make sure the find in cygwin is called by either using full path or insert cygwin bin path before system32 because Windows also has a find.exe.




ANSWER 4

Score 0


you could download sed with gnuwin32. This prepends the current directory.

Doing %cd% doesn't work.. so %cd:\=\\% converts every \ to \\, which results in \.

C:\WINDOWS>dir /b | sed "s/^/%cd:\=\\%\\/" 
C:\WINDOWS\0.log
C:\WINDOWS\003109_.tmp
C:\WINDOWS\addins