Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Batch: list files and folders and size in a csv file v2 (drill down or not drill down option)

Hello experts,

i use the following batch reported at: https://www.experts-exchange.com/questions/29104866/Batch-list-files-and-folders-and-size-in-a-csv-file.html?anchorAnswerId=42604039#a42604039

in order to list files and folders into a csv:
@echo off
setlocal EnableDelayedExpansion

set BaseDir=c:\temp
set ListFile=list.csv

if exist "%ListFile%" del "%ListFile%"

echo "File_Folder_Path";"Type";"File_Folder_Size">>"%ListFile%"

for /f "tokens=*" %%A in ('dir /s /b "%BaseDir%\*.*"') do (
    for %%B in ("%%~A") do (
        if exist "%%~A\" (set FileType=D) else (set FileType=F)
        echo "%%~A";"!FileType!";%%~zB>>"%ListFile%"

Open in new window


By default the procedure drill down the various files and folders.
I would like to add a flag drill down option. If Yes drill down else just list files and folders at basedir level.

If you have questions, please contact me.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Luis Diaz

ASKER

Thank you Bill for this proposal.
Unable to test it today I will test it tomorrow.
Test it and it works.
Thank you very much for your help!
Avatar of Bill Prew
Bill Prew

Welcome.


»bp