Batch File

G

Guest

Anyone know how to create a batch file that will give you the size of a file
and execute a task. For example if a zip file is less than 1mb delete it.
 
P

Phil Robyn

John said:
Anyone know how to create a batch file that will give you the size of a file
and execute a task. For example if a zip file is less than 1mb delete it.

- - - - - - - begin screen capture WinXP MCE 2005 SP2 - - - - - - -
c:\cmd>dir \download\*.zip
Volume in drive C has no label.
Volume Serial Number is 44E5-91F9

Directory of c:\download

02/28/2006 08:36 AM 285,580 Autoruns.zip
04/03/2006 03:51 PM 86,723 getkv11.zip
04/09/2006 03:58 PM 109,615 hosts.zip
03/29/2006 01:20 PM 2,202,048 monad_b3_1_50727_x86.zip
03/29/2006 01:20 PM 266,830 monad_b3_docs.zip
02/01/2006 06:42 PM 739,932 private.zip
02/28/2006 08:32 AM 648,737 ProcessExplorerNt.zip
02/02/2006 02:36 PM 592,469 PsTools.zip
02/02/2006 02:35 PM 24,249 SDelete.zip
02/27/2006 11:13 PM 1,442,494 sonicencoders.zip
04/07/2006 09:34 PM 3,803,503 why_ruby_sucks_PPT.zip
02/01/2006 06:42 PM 636,111 xyplorer_full.zip
12 File(s) 10,838,291 bytes
0 Dir(s) 218,477,404,160 bytes free

c:\cmd>for %a in (c:\download\*.zip) do @if %~za lss 1000000 echo
deleting %~ta %~za %~fa
deleting 02/28/2006 08:36 AM 285580 c:\Download\Autoruns.zip
deleting 04/03/2006 03:51 PM 86723 c:\Download\getkv11.zip
deleting 04/09/2006 03:58 PM 109615 c:\Download\hosts.zip
deleting 03/29/2006 01:20 PM 266830 c:\Download\monad_b3_docs.zip
deleting 02/01/2006 06:42 PM 739932 c:\Download\private.zip
deleting 02/28/2006 08:32 AM 648737 c:\Download\ProcessExplorerNt.zip
deleting 02/02/2006 02:36 PM 592469 c:\Download\PsTools.zip
deleting 02/02/2006 02:35 PM 24249 c:\Download\SDelete.zip
deleting 02/01/2006 06:42 PM 636111 c:\Download\xyplorer_full.zip

- - - - - - - end screen capture WinXP MCE 2005 SP2 - - - - - - -
 
G

Guest

Phil, thank you for the reply however the files are not actually being
deleted. It says they are but when you do a dir on the folder they are still
there. Any ideas?
 
P

Phil Robyn

John said:
Phil, thank you for the reply however the files are not actually being
deleted. It says they are but when you do a dir on the folder they are still
there. Any ideas?

:

My example said 'echo deleting ...' to show you what would be deleted.
If you are satisfied that the right files would have been deleted, then
you have to change 'echo deleting %~ta %~za %~fa' to 'del "%~fa"' in
order to actually delete any files.

My example was not a batch file per se, but rather a single command
issued from the CMD prompt. If you want to put this in a batch file,
then you have to double the percent signs, e.g., '%%a', '%%~fa'.
 
G

Guest

No problem Thanks Again. You seem to be very knowlegeable so maybe you can
answer this question. We would like to be able to disable users from closing
DOS windows by clicking the "X". Any ideas?
 
P

Phil Robyn

John said:
No problem Thanks Again. You seem to be very knowlegeable so maybe you can
answer this question. We would like to be able to disable users from closing
DOS windows by clicking the "X". Any ideas?

What exactly are you trying to do? Can you elaborate a bit? There may be some
other way to accomplish your goal.
 
G

Guest

We just want to prevent users from clicking the "x" in any DOS window. If
that involves removing it, graying it out whatever, we just dont want users
to be able to close the window by pressing the X. We use a DOS based POS
program in our retail stores and need this to elimanate data corruption that
is caused by terminating the program when clicking the X. Any help is always
appreciated.
 
B

Bob I

Make it full screen, not a window?
We just want to prevent users from clicking the "x" in any DOS window. If
that involves removing it, graying it out whatever, we just dont want users
to be able to close the window by pressing the X. We use a DOS based POS
program in our retail stores and need this to elimanate data corruption that
is caused by terminating the program when clicking the X. Any help is always
appreciated.

:
 
P

Phil Robyn

John said:
Phil, here is an example of a program that does exactly what we want. I guy
who wrote it wont give us the code so we can look at it.
http://www.uwe-sieber.de/files/consolenoclose.zip

Since his is free, why not just use his? Why do you need to look at the source
code if it already does exactly what you want? And why do you think he should
be obligated to give you the source code?

His program is written in Visual Basic. If you really want to see some source
code that does what you are asking, you can search around in VB newsgroups or
on the many VB web sites. I have seen example VB code for this before (a few
years ago).
 
G

Guest

Phil, we want the source code just to make sure it isnt doing anything it
shouldnt be doing since this would be in a corporate enviroment. Thanks for
all your help.
 
P

Phil Robyn

John said:
Phil, we want the source code just to make sure it isnt doing anything it
shouldnt be doing since this would be in a corporate enviroment. Thanks for
all your help.

You're welcome. Maybe Uwe would be willing to sell his source code to you.
Depending on the size of the 'corporate environment' and the importance of the
application, it might be worth it to either purchase Uwe's source code or to
pay a developer to produce a similar product for you.
 
G

Guest

12:43 10-Jun-06

batchfile query


Query for Phil Robyn...

Sorry to barge in like this but couldn't resist. If you're deep into
batchfiles,

perhaps
you would know of a 'simple' way to simulate the not-so-old and one of the
most
useful ever DOS commands: "command/y/c" to step thru and de-bug batchfiles.

It appears it's been eliminated from under XP and the new DOS command
scenario
they're using nowadays is a bit over my head. I've had to really battle to
get some

of my old (and new) batchfiles running OK under Win XP Pro (SP2). The
'pause'
command helps but it's cumbersome and some of the curt and cryptic error
messages don't help any either.

I've been told there's a way to do it via the SET/p command but couldn't get
that
working right - probably because I couldn't obtain a simple step-by-step
example.
There's nothing like a good, working sample script to show the way.

Someone also wrote some code for doing it but it's quite long and complex.
Seems odd that there's no simple substitute command available for doing such
an
essential task (for DOS hangers on, anyway).

Any ideas?

Might browse around and post some more. Getting really frustrated over this.
Tried for months now...
 
P

Pegasus \(MVP\)

tedoniman said:
12:43 10-Jun-06

batchfile query


Query for Phil Robyn...

Sorry to barge in like this but couldn't resist. If you're deep into
batchfiles,

perhaps
you would know of a 'simple' way to simulate the not-so-old and one of the
most
useful ever DOS commands: "command/y/c" to step thru and de-bug batchfiles.

It appears it's been eliminated from under XP and the new DOS command
scenario
they're using nowadays is a bit over my head. I've had to really battle to
get some

of my old (and new) batchfiles running OK under Win XP Pro (SP2). The
'pause'
command helps but it's cumbersome and some of the curt and cryptic error
messages don't help any either.

I've been told there's a way to do it via the SET/p command but couldn't get
that
working right - probably because I couldn't obtain a simple step-by-step
example.
There's nothing like a good, working sample script to show the way.

Someone also wrote some code for doing it but it's quite long and complex.
Seems odd that there's no simple substitute command available for doing such
an
essential task (for DOS hangers on, anyway).

Any ideas?

Might browse around and post some more. Getting really frustrated over this.
Tried for months now...

I'm not sure if you will get a reply from Phil - I haven't seen
him around here for a while.

The batch file debugging mode you refer to was never implemented
in WinNT/2000/XP. As you say, inserting a number of strategically
placed "pause" commands is tedious but your only option.

The set /p command will prompt the user for a reply. It is not a
debugging tool.

You write "XP and the new DOS command scenario". Note that
there is no DOS under WinXP - it's the Command Prompt. DOS
is an operating system on its own and there is no room for it
under Windows.
 
G

Guest

Roger on all that. Appreciate. Still, I think I'll keep on trying. Might
be someone
out there somewhere who's done something simple about it. Who knows.

--
Ted...


Pegasus (MVP) said:
You write "XP and the new DOS command scenario". Note that
there is no DOS under WinXP - it's the Command Prompt. DOS
is an operating system on its own and there is no room for it
under Windows.

Am aware of that. Just don't express myself very well. Not qualified to
argue the point but somehow don't think 'no room ... ' is the whole
explanation. More like tactics and policy.

Thanx...

T...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top