Not able to output to file in the Windows command line
Posted
by
Sachin
on Super User
See other posts from Super User
or by Sachin
Published on 2012-10-10T15:09:26Z
Indexed on
2012/10/10
15:40 UTC
Read the original article
Hit count: 323
In the following code, I need to take the path and size of folder and subfolders into a file. But when the loop runs for the second time, path and size are not getting printed to the file. size.txt only contains the path and size of the 1st folder. Please somebody help me.
@echo off
SETLOCAL EnableDelayedExpansion
SET xsummary=
SET xsize=
for /f "tokens=1,2 delims=C" %%i IN ('"dir /s /-c /a | find "Directory""') do (echo C%%j >> abcd.txt)
for /f "tokens=*" %%q IN (abcd.txt) do (
cd "%%q"
For /F "tokens=*" %%h IN ('"dir /s /-c /a | find "bytes" | find /v "free""') do Set xsummary=%%h
For /f "tokens=1,2 delims=)" %%a in ("!xsummary!") do set xsize=%%b
Set xsize=!xsize:bytes=!
Set xsize=!xsize: =!
echo.%%q >> size.txt
echo.!xsize! >> size.txt
)
© Super User or respective owner