0

Here is my question:

How would I go about getting a list of all folders in the specific directory and .exe's.

The format is as follows

z:\xxxxxx\appdata\roaming

I want the batch file to look through every folder aka xxxxxx Z: looks like

z:\xxxxxx
z:\xxxxxx
z:\xxxxxx
z:\xxxxxx
z:\xxxxxx

And in each xxxxxx folder I want it to get the folder names in appdata & any .exe's then enter the roaming folder and get all folder names & any .exe names.

Then I want to output it to a specific z:\xxxxxx\desktop\output.txt

The output should look like

z:\xxxxxx
--------------------- app data --------------------
roaming
example folder2
example.exe
--------------------- roaming ---------------------
example folder1
example folder2
example folder3
example folder4
example folder5
example folder6
example1.exe
example2.exe
---------------------------------------------------

and so and so forth for the rest of the z:\xxxxxx folders

I also want it to list hidden folders if possible.

I have some batch code I have started with but I am pretty lost I will post it tomorrow.

Taylor Hx
  • 2,815
  • 23
  • 36
  • possible duplicate of [Batch Files: List all files in a directory with relative paths](http://stackoverflow.com/questions/8385454/batch-files-list-all-files-in-a-directory-with-relative-paths) – unclemeat Jan 16 '14 at 05:50

1 Answers1

1

See if this floats your boat:

EDIT: corrected some lines

@echo off
set "drv=z"
for /d %%a in (%drv%:\*) do (
  (
    echo %%a
    echo --------------------- app data --------------------
    dir "%%a\appdata" /ad /b 
    dir "%%a\appdata\*.exe" /a-d /b 
    echo --------------------- roaming ---------------------
    dir "%%a\appdata\roaming" /ad /b 
    dir "%%a\appdata\roaming\*.exe" /a-d /b 
    echo ---------------------------------------------------
  )> "%%a\desktop\output.txt"
)
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • Your code is virtually the same as mine except I couldn't figure how to make it enter the first user directory z:\xxxxxx unfortunatly after running your code I got a bunch of "The specified path is invalid" for each folder. And the output log looked like this. z:\z:\xxxxxx ---- app data ---- ---- roaming ----- ------------------ This was the TOTAL output log and the xxxxxx was the last folder at the very bottom so for some reason only the bottom folder was logged and it didn't pick up the contents of app data / roaming because the specified path was invalid. – user3201060 Jan 17 '14 at 03:01
  • Copy and paste it again. I changed some variables. – foxidrive Jan 17 '14 at 03:36
  • It worked excellent with just the slight change of >> instead of > so I don't overwrite :P I have a later project where I will be doing something similar to this but with computers on the network, these ones just happen to be in a networked drive. Thanks! – user3201060 Jan 17 '14 at 03:45