modify batch file

October 24, 2011 at 10:58:34
Specs: Windows 7
I have a batch file that I need to modify. It currently lists a number of file types and their locations - how would I add the file size to the following?

@echo off
if exist C:\Users\Administrator.domain\Desktop\kresults.txt del /q C:\Users\Administrator.domain\Desktop\kresults.txt
FOR %%G IN (
jpg
tif
bmp
png
mp3
mp4
mov
) DO (
echo Searching for %%G
dir D:\ROAMING\*.* /L /A /B /S|Find "%%G" >> C:\Users\Administrator.domain\Desktop\kresults.txt
)
If not exist C:\Users\Administrator.domain\Desktop\kresults.txt echo "Files not found" >> C:\Users\Administrator.domain\Desktop\kresults.txt
start notepad C:\Users\Administrator.domain\Desktop\kresults.txt
exit

Thanks!


See More: modify batch file

Report •


#1
October 24, 2011 at 17:04:32
The /B in the statement:

dir D:\ROAMING\*.* /L /A /B /S|Find "%%G" >>

means bare... meaning it strips away all the other file info other than the name. If you remove the /B from that statement like this:

dir D:\ROAMING\*.* /L /A /S|Find "%%G" >>

You will see all of the other file info. If you only want file size, then this will show you more than what you want, and changing it would take a few extra steps.


Report •

#2
October 25, 2011 at 09:47:45
That is perfect! Thanks!

Report •

#3
October 25, 2011 at 13:13:03
Anytime tracys.

Report •

Related Solutions

#4
October 27, 2011 at 09:36:46
I am getting great size information with this removal of the BARE command; one thing does seem to be missing is the file path - am I missing something?

Thanks


Report •

#5
October 27, 2011 at 09:46:07
Can you send me an example of what you are seeing, and an example of what you would like to see?

Report •

#6
October 27, 2011 at 10:13:31
Thanks jowah, here's an example:

With/B removed:

04/01/2010 10:03 AM 6,975 top-chef-masters2.jpg
04/01/2010 10:03 AM 5,630 watch-what-happens.jpg
04/01/2010 10:03 AM 5,155 9bydesign-100x70.jpg
04/01/2010 10:03 AM 2,214 btn_submenu_viewall.jpg
04/01/2010 10:03 AM 20,290 casting-3-160x120.jpg

with /B in place:

e:\roaming\alice\desktop\$recycle.bin\$i56ofii.jpg
e:\roaming\alice\desktop\$recycle.bin\$r56ofii.jpg
e:\roaming\alice\desktop\$recycle.bin\$rhbrgug\11-small.jpg
e:\roaming\alice\desktop\$recycle.bin\$rmdfy0e\9bydesign-100x70.jpg
e:\roaming\alice\desktop\$recycle.bin\$rmdfy0e\bravogbb-ads-300x250.jpg


Report •

#7
October 27, 2011 at 15:12:58
Hmmm... this seems to be a catch 22 for your situation. If you use /b without /s, or /s without /b you won't see the full path. I'm sure there is a way to do it though. Let me think about it and I'll see what I can come up with.

Report •

#8
October 27, 2011 at 15:24:41
Appreciate the help!

Report •

#9
October 28, 2011 at 05:38:00
Know what I like about the original solution? This.is.not.a.jpg.this.is.only.a.tribute.txt would be caught, while Rockin.Tunes.MP3 would not. Just throwing that out there.

EDIT: Untested, but far more compact:

set outFile=C:\Users\Administrator.domain\Desktop\kresults.txt
echo "Files not found" > %outFile%
(FOR /R "D:\ROAMING" %%G IN (*.jpg *.tif *.bmp *.png *.mp3 *.mp4 *.mov
) DO @echo %%~fG %%~zG) > %outFile%
notepad %outFile%

How To Ask Questions The Smart Way


Report •

#10
October 28, 2011 at 11:17:26
Hey Razor2.3, will give that a shot. Thanks!

Report •

Ask Question