Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Batch file to list directories, export to CSV

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 16-02-2009
chickenfriedsteak
 
Posts: n/a
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.

Reply With Quote
  #2  
Old 16-02-2009
chickenfriedsteak
 
Posts: n/a
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
Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Batch file to list directories, export to CSV"
Thread Thread Starter Forum Replies Last Post
scripts to list all users, home directories, and their home directories sizes ngwodo Technology & Internet 3 16-07-2011 03:03 AM
make file name list in excel using batch file shibinpanayi Windows Software 1 04-06-2011 03:44 AM
code for using a batch file to parse html (.htm) files and export values in .csv format jamesnovello Software Development 1 19-03-2011 01:28 AM
run Batch-file export in excel (its for a Movie database) rayg Software Development 4 22-12-2010 07:31 PM
Batch file to compare directories Lauren Ambrose Software Development 5 31-03-2010 11:08 AM


All times are GMT +5.5. The time now is 07:17 AM.