Reputation: 85
How to please store the names of the directories to C:\maindir\ to file C:\export.txt ? Only directory, no files.
My directories
C:\maindir\dir1
C:\maindir\dir2
C:\maindir\dir3
export format file C:\export.txt
mytext dir1
mytext dir2
mytext dir3
Consult someone please ? Thank you
Upvotes: 0
Views: 29
Reputation: 176016
You can;
for /f "delims=" %%a in ('dir /b /ad c:\maindir') do echo mytext %%a >> C:\temp\export.txt
(Note on recent versions of windows you cannot write to the root of C:)
Upvotes: 1
Reputation: 82
You must get the list of the files in a variable (say FILELIST) and then perform a loop:
for i in $FILELIST; do
if [ -d $i ]; then
echo $i >> c:\export.txt
fi
done
This must do what you need.
Upvotes: 0