Results 1 to 2 of 2

Thread: Batch file to list directories, export to CSV

  1. #1
    chickenfriedsteak Guest

    Batch file to list directories, export to CSV

    Good morning:

    A while ago I had a batch file I put together with a little help from
    some tutorials to scan through a list of directories kept in a
    separate TXT file, echo the size of each directory on the screen, and
    also echo them out to a CSV file (DIRECTORY,SIZEinBYTES). I'm using
    it to do a quick poll of the size of users personal folders on our
    network share, so first it would map the root of the shar drive as Z:
    \, then it would go through each one in the list I created and give
    the size of all the data contained in that directory.

    Can anyone point me to a website with this code? I've been on Google
    all morning but can't find the website I used.

  2. #2
    chickenfriedsteak Guest

    Re: Batch file to list directories, export to CSV

    On Feb 16, 9:50*am, chickenfriedsteak <ow...@chickenfriedsteak.us>
    wrote:
    > Good morning:
    >
    > A while ago I had a batch file I put together with a little help from
    > some tutorials to scan through a list of directories kept in a
    > separate TXT file, echo the size of each directory on the screen, and
    > also echo them out to a CSV file (DIRECTORY,SIZEinBYTES). *I'm using
    > it to do a quick poll of the size of users personal folders on our
    > network share, so first it would map the root of the shar drive as Z:
    > \, then it would go through each one in the list I created and give
    > the size of all the data contained in that directory.
    >
    > Can anyone point me to a website with this code? *I've been on Google
    > all morning but can't find the website I used.


    Just a minute after I posted this, I found what I was looking for.
    For anyone interested:

    @echo off
    set servlist=c:\serverlist.txt
    if not exist %servlist% echo %servlist% not found & pause & goto end

    set listfile=c:\dirsize.csv


    for /f "tokens=*" %%a in (%servlist%) do call :process %%a

    goto end

    :process

    for /f "tokens=3" %%x in ('dir %1 /-c/s ^| find "File(s)"') do set
    total=%%x

    echo %1, %total%
    echo %1, %total% >> %listfile%

    :end

Similar Threads

  1. Replies: 3
    Last Post: 16-07-2011, 03:03 AM
  2. make file name list in excel using batch file
    By shibinpanayi in forum Windows Software
    Replies: 1
    Last Post: 04-06-2011, 03:44 AM
  3. Replies: 1
    Last Post: 19-03-2011, 01:28 AM
  4. run Batch-file export in excel (its for a Movie database)
    By rayg in forum Software Development
    Replies: 4
    Last Post: 22-12-2010, 07:31 PM
  5. Batch file to compare directories
    By Lauren Ambrose in forum Software Development
    Replies: 5
    Last Post: 31-03-2010, 11:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •