I've got a folder hierarchy in which I need to create a directory listing inside each main folder, showing the result of "dir /b /s *.* > index.txt".
For example, in
root folder
root folder\main_folder_1\some_more_subfolders\files
root folder\main_folder_2\some_more_subfolders\files
I need to be able to run a batch from within \root folder\. That batch needs to deposit a separate index.txt file into each \main_folder_#\ containing the contents of \main_folder_#\ and its subfolders. I've been able to output a main directory index.txt file into \root folder\ but I can't figure out how to deposit separate index.txt files into each \main_folder_#\ branch. Any help would be appreciated!
m1
Help w/ batch file to output dir listings in subdirectories
Moderator: DosItHelp
Re: Help w/ batch file to output dir listings in subdirector
Code: Select all
@echo off
for /d %%a in (*) do dir "%%a" /b /s >"%%a\index.txt"
Re: Help w/ batch file to output dir listings in subdirector
Very nice, thanks for that. It works great!
I wonder, is there any way to eliminate the 'higher' level directories from what is recorded in the output file? For example, if the batch is run from:
e:\Archive\Images\January\
and it's recording the following path, as an example:
e:\Archive\Images\January\Exterior\Resource\Image_001.tif
Then the path stored in the output.txt would read:
\Exterior\Resource\Image_001.tif
and eliminate all of the path "above" the directory from which it was run...?
m1
I wonder, is there any way to eliminate the 'higher' level directories from what is recorded in the output file? For example, if the batch is run from:
e:\Archive\Images\January\
and it's recording the following path, as an example:
e:\Archive\Images\January\Exterior\Resource\Image_001.tif
Then the path stored in the output.txt would read:
\Exterior\Resource\Image_001.tif
and eliminate all of the path "above" the directory from which it was run...?
m1