title: Batch script to generate a csv file containing the subfolder name and size of a particular log file w.r.t each user
body: <p>I have a folder named Folder1. Inside Folder1 have some sub-folders (a,b,c,d,e...) Inside each sub-folder there is a log file with same name across all the sub-folders (test.log). size of each log files are different. I need to generate a csv file containing the sub-folder name and size of a particular log file w.r.t each user. </p>
  
  <p>eg: my output should be</p>
  
  <p>a 180</p>
  
  <p>b 220</p>
  
  <p>c 450 </p>
  
  <p>I tried writing a code by searching in Google.</p>
  
  <pre><code>@ECHO OFF
  SetLocal EnableDelayedExpansion
  
  rem To put the sub-folder names inside the Folder1 into a text file try.txt
  
  pushd C:\....\Folder1\*
  for /f "delims=" %%f in ('dir /b /ad') do echo %%f &gt;&gt; try.txt
  popd
  
  
  rem To put the values inside a text file(try.txt) into a variable %Build% (but the values are place horizontally with spaces; it is not inserting vertically) 
  
  pushd C:\....\Folder1\try.txt\*
  for /f "delims=" %%f in (try.txt) do set Build=!Build!%%f
  popd
  
  echo %Build%'\n' &gt;&gt; bb.log
  </code></pre>
  
  <p>My idea was to put the sub-folder names in a text file called try.txt and put the values inside the text files into a vaiable %Build%. then go to the path where the log file is present to get the size. like below.</p>
  
  <pre><code> for /f %%i in ("C:\....\Folder1\%Build%\....\test.log") do set "size=%%~zi" &gt;&gt; output.csv
  </code></pre>
  
  <p>Please help me out as I am new to batch scripting. </p>
  
  <p>How can I modify the same script if conditions are like below. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>C:\Users\&lt;username&gt;\AppData\Roaming\sys.log 
  
  where my output should be:
  
  &lt;username1&gt; sys.log file size (for each usernames under C:\Users) 
  &lt;username2&gt; sys.log file size
  &lt;username3&gt; sys.log file size</code></pre>
  </div>
  </div>
  </p>