batch script with ‰ deleting...maybe MB saved

July 31, 2012 at 11:11:30
Specs: windows 7, i7
So, after helping our a few,deleting crap,weening some
Off of AOL,I started to write simple bat scripts, like, deleting
Temp,pre fetch,internet files,firefoxcache, etc. This would be
In the startup folder, every now and then there are huge files,
That look like its stalled...they are presentation,flash.. etc


So I was wondering if I could make it read back the percentage complete...
It was harder then I thought. The script deletes stuff,its handful of crap one day,the next its
alot. So the amount would change.

I also thought about putting in a total amount of space saved..
But It too was a bit hard.

So I was wondering,
What would be the command to place in my current script,or a new one.
Ive never done CBS,that's more detailed though.

Thanks

O.s. are win7


See More: batch script with ‰ deleting...maybe MB saved

Report •

#1
November 17, 2012 at 10:45:49
If there is a main batch file, when it calls each separate batch(if that is how you are doing this) you could:

echo process one completed....

or you could change the title to state what process you are on

title current process....whatever.

:: mike


Report •

#2
November 17, 2012 at 12:24:29
Fun fact: The going rate for a 3TB hard drive is $124.95 (USD). That's roughly $0.04 per gigabyte. Unless you're saving 1.11GB, your efforts add up to less than a nickel.

How To Ask Questions The Smart Way


Report •

#3
November 17, 2012 at 12:34:08
Yeah, i put together an eighty gig drive from old components for $1.23 a couple of months ago for fun..

:: mike


Report •

Related Solutions

#4
November 18, 2012 at 04:14:49
This will be pretty hard this is what I have so far and don't have much time, will work on it later:
@echo off & setlocal enabledelayedexpansion
set number=0
set size=0
echo.WScript.Echo Eval(WScript.Arguments^(0^)^)> %tmp%\percentagecalculator.vbs
> %tmp%\list.txt (
echo.1foldertodelete
echo.2ndfoldertodelete
)
for /f "delims=" %%a in ('type %tmp%\list.txt') do (
set /A number +=1
set folder!number!=%%a
)
for /f "delims=" %%a in ('dir /b !folder%number%!') do (
set /A file +=1
set !file!=%%a
)
:Size
for /r %%x in (!folder%number%!\*) do set /a size+=%%~zx
set total=%size%
set loops=0
:LOOP
set /A loops +=1
del !%file%!
call :Size
for /f %%n in ('cscript //nologo %tmp%\percentagecalculator.vbs "100\(%total%\%size%)"') do (
set res=%%n
)
echo.Progress:%res%^%
if %loops%==%file% if "%number%" NEQ "0" (set /A number -=1 & set loops=0)
Goto :LOOP

That's for checking the percentage of the process.

Report •

#5
November 18, 2012 at 11:55:24
If you want to be flashy, this will create and demo a standard "progress bar", but it needs either debug or vbscript to create a small binary (.com) file:
AND, as razor pointed out, only works on 32-or-less-bit systems!
::====== begin script "progbar.bat"
@goto :aaa
e100 B4 03 CD 10 80 FE 01 72 07 80 EE 01 B4 02 CD 10 CD 20 DB
rcx
13
w
q
:aaa
:: demonstrates a "progress bar" using "up.com"
@echo off & setlocal
if exist up.com goto :zero
debug up.com <%dpn0.bat 2>nul >nul
:zero
for /f "tokens=* delims=" %%a in (up.com) do set blok=%%a
set blok=%blok:~-1%
set /a nn=1
set bb=
:one
set bb=%bb%%blok%
echo %bb%
set /a nn+=1
if %nn% equ 80 goto :eof
up
goto :one
::===== end script

If you unfortunate enough to not have debug, this vbscript can build the binary:
'====== begin vbscript
set fso=createobject("scripting.filesystemobject")
set up=fso.createtextfile("up.com")
z=chr(&HB4)+chr(&H03)+chr(&HCD)+chr(&H10)+chr(&H80)+chr(&HFE)+chr(&H01)
z=z+chr(&H72)+chr(&H07)+chr(&H80)+chr(&HEE)+chr(&H01)+chr(&HB4)+chr(&H02)
z=z+chr(&HCD)+chr(&H10)+chr(&HCD)+chr(&H20)+chr(&HDB)
up.write z
'====== end vbscript

To use the bar in this application, first you would need to divide the total size of all the combined files by 80 (or whatever size you want the bar to be, i used standard screen width).
f/e call this "bloksize"
Then, as your batch works, it would keep a running total of sizes of files deleted. Whenever the total modulo bloksize is zero, call progbar to display another block.
(or if you don't like modulo, just zero the counter each time it hits bloksize).

But I'm doubtful of the utility of this whole concept, because deleting even large files just doesn't take much time. One byte is modified in the directory, and the allocation table is freed up. The file itself is not actually deleted or modified.

ps: if you're scared of the binary executable, maybe this listing will make you more comfortable:


B403 MOV AH,03 move 3 into AH
CD10 INT 10 this interrupt gets the cursor position
80FE01 CMP DH,01 compare dh,1
7207 JB 0110 jump to exit if less than 1
80EE01 SUB DH,01 subt. 1 from current cursor posn.
B402 MOV AH,02 move 2 into AH
CD10 INT 10 this interrupt sets the cursor up one line
CD20 INT 20 this interrupt exits the program politely
DB this is the block character (219 dec.)

Report •

#6
November 18, 2012 at 12:23:07
If you unfortunate enough to not have debug, this vbscript can build the binary:
If you have a version of Windows without DEBUG.COM, there's a reason:
M:\>wmic cpu get addressWidth
AddressWidth
64


M:\>up.com
This version of M:\up.com is not compatible with the version of Windows you're 
running. Check your computer's system information to see whether you need a x86 
(32-bit) or x64 (64-bit) version of the program, and then contact the software 
publisher.

How To Ask Questions The Smart Way


Report •

#7
November 18, 2012 at 12:32:58
yeh, you have a point there Razor. Although my win-7 does include debug and runs the binary (it being a 32-bit machine)... Also, there is always the possibility that some vile and reprehensible miscreant deleted debug!

Report •

Ask Question