Computer Hope

Microsoft => Microsoft DOS => Topic started by: DaveLembke on December 28, 2010, 08:47:07 PM

Title: Echo. >>smallfiles.txt file names less than 200k in size???
Post by: DaveLembke on December 28, 2010, 08:47:07 PM
Was wondering if anyone had any suggestions on a way to search through a directory for files less than 200k in size and write them as a ascii text file.

I know how to write the output from DOS to a file, but I need to find a way to find files that are less than 200k in size from DOS on a Windows XP Pro SP3 system.

* The reason for why the solution is not as easy as a one time use of windows explorer to just sort by file size and then move files to another folder and then perform a DIR command with >>smallfiles.txt is that I want to add this to an automated process that checks and corrects for files that are too small to be correct. Another program that I wrote in C++ will read in the list of file names from that text file and rerun the process for those tasks that were executed with bad file results.

Any language can be used to make this happen, and I was curious as to if batch could be used or if a vbscript or other language would be necessary and if so, how do go about grabbing file names less than 200k in size?
Title: Re: Echo. >>smallfiles.txt file names less than 200k in size???
Post by: ghostdog74 on December 28, 2010, 11:32:26 PM
if you want a native solution you can use vbscript. See here (http://www.computerhope.com/forum/index.php?topic=55868.0) for an example.
If you can afford to download stuff, you can use GNU find for windows (http://www.computerhope.com/forum/index.php/topic,106986.msg722720.html#msg722720) with -size option.

Of course, since you are already coding in C++, why not just use C++? Otherwise, languages like Perl/Python etc can also find file sizes for you.
Title: Re: Echo. >>smallfiles.txt file names less than 200k in size???
Post by: DaveLembke on December 29, 2010, 04:03:40 AM
Thanks! The VBScript link will pobably be most helpful to me. I searched and didnt come across it here prior to posting. Not sure how I missed it when the subject is just about the same.
Title: Re: Echo. >>smallfiles.txt file names less than 200k in size???
Post by: Salmon Trout on December 29, 2010, 11:47:21 AM
I was curious as to if batch could be used

Code: [Select]
@echo off
for /f "delims=" %%A in ('dir /b /a-d') do (
    if %%~zA lss 204800 echo file %%A is less than 200 kB
    )
Title: Re: Echo. >>smallfiles.txt file names less than 200k in size???
Post by: DaveLembke on December 29, 2010, 02:30:36 PM
Thank You Salmon Trout for showing a way to do this in batch!!!!! 8)