Click here for important information about

DOS Batch File - Writing

Eidos Batman: arkham asylum (ps3)
April 7, 2010 at 10:11:37
Specs: Windows XP
Hi: I need to write a batch file that will look for a file and records the file size and then logs the file name AND file size in a text file or even better yet in an excel type file so that it can be brought into a database. Is there a way to do that?

Thanks, Nikki

See More: DOS Batch File - Writing

April 7, 2010 at 10:23:08
DOS Batch File
OS: Windows XP
XP is to DOS as a Semi-trailer truck is to a ridding lawnmower.
Pick an Operating System.

then logs the file name
How do you plan on finding a file whose name you do not know?

Answer these two questions, and then we'll talk.

Report •

April 7, 2010 at 10:37:30
Sorry, I'm probably not the most intelligent person in the world, but I am just trying to avoid having to go out and look at 4000 files in a given directory and find each name & file size to put in an importable file format.

I am on XP and am trying to look at all file names under a given directory and then record the file name/file size in an importable (to Access) format.

I don't even know if something such as this is possible but if it is, I would love to learn how to accomplish this but on a path that would make me feel as little like a moron as possible. Your help would be greatly appreciated.


Report •

April 7, 2010 at 10:50:10
Added information:

Say I am going out to a mapped share (drive):

I am going to say V:\PROD and in that directory I see all the file folders (sub-directories) in each there are PDF files and additional subdirectories. I need to list all folder/directory names, (1st level) under the PROD and what the folder size would be. Example

V:\PROD has the following files:


I need a text (importable type document) that will list the following:

01-AAA02 2.3mb
01-RRR-03 1.5mb
and so on. Hope this help figure out my situation. Thanks!

Report •

Related Solutions

April 7, 2010 at 11:02:00
Okay so now I have learned that what is wanted was JUST the directory name and directory size in the importable file format. In other words:

V:\PROD has the following directories


I need the text or importable (to Access) format to read the directory name and log:

00-250-200 1.2mb
00-251-201 1.7mb

Etc! Thanks

Report •

April 7, 2010 at 11:18:41
(for %%a in (v:\PROD\*) do @echo %%~Za, %%a) > out.csv

Reported sizes will be in bytes.

Report •

April 7, 2010 at 11:49:36
This is awesome but is there any way to capture the directory size instead of the file? I know the directories don't keep the size listed but the files do. I need the total count of everything in that directory.

Thanks so much for your awesome help!

Report •

April 7, 2010 at 13:32:30
That's difficult. Partly because as soon as the byte count hits 2GB, the data overflows and your byte count will be incorrect.

The easiest solution would be to change languages. Here's a VBScript:

With CreateObject("Scripting.FileSystemObject")
  Set out = .OpenTextFile("out.csv", 2, True)
  For Each f In .GetFolder("V:\PROD").SubFolders
    out.WriteLine f.Name & "," & f.Size
  Next 'f
End With

Report •

April 8, 2010 at 05:13:28
Thanks so much but I am limited here to the use of the DOS type batch to achieve this and if I cannot figure out a way then I simply have to look at each file independently and the manually log the folder size.

Thanks a million for trying – wished it could be done with the Batch file. Nicole

Report •

April 8, 2010 at 05:45:46
I'm curious as to why you're limited to batch. Anything I'd offer in that language would only work on the WinNT line (WinNT, 2K, XP, Vista, 7), and VBScript is the "more native" language on those systems.

Report •

April 9, 2010 at 08:28:48
Don't have any other software loaded or access to & don't know any of those other languages either. Want to teach me how to do this? :-D

Thanks so much, Nicole

Report •

Ask Question