Thread View: alt.msdos.programmer
9 messages
9 total messages
Started by Nathan Owen
Wed, 12 Aug 1992 13:26
Need DOS batch help!
Author: Nathan Owen
Date: Wed, 12 Aug 1992 13:26
Date: Wed, 12 Aug 1992 13:26
7 lines
822 bytes
822 bytes
I having a problem writing a batch file. I need a batch file which will go to a c:Temp directory and delete every file in the directory except for a file named gest.bat. The batch must be written in such a way they the user will not get a message asking Yes/No (Y/N) in response to deleting the files , which limits your use of wildcard deletes like del *.*. Thanx in advance.
Re: Need DOS batch help!
Author: Chanh N. Vuong
Date: Wed, 12 Aug 1992 14:15
Date: Wed, 12 Aug 1992 14:15
34 lines
1659 bytes
1659 bytes
In article <92225.09262732BFPQ3@CMUVM.CSV.CMICH.EDU> Nathan Owen <32BFPQ3@CMUVM.CSV.CMICH.EDU> writes: >I having a problem writing a batch file. I need a batch file which will go >to a c:\Temp directory and delete every file in the directory except for >a file named gest.bat. The batch must be written in such a way they the >user will not get a message asking Yes/No (Y/N) in response to deleting >the files , which limits your use of wildcard deletes like del *.*. > >Thanx in advance. Here goes: DEL_TEMP.BAT: @echo off c: cd \ cd temp md tmp copy gest.bat tmp for %%a in (*.*) do del %%a copy c:\temp\tmp\gest.bat . del c:\temp\tmp\gest.bat rd tmp cd \ *The End* +------------------------------------------------------+ | |\/\/\/| Chanh N. Vuong (aka Cee Vee) | | | | chanh@athena.mit.edu | | | (o)(o) (617)225-6302 or x5-6302 | | C _) | | | ,___| Hey, like don't eat a cow, man! | | | / ----------------------------------------------+ | /____\ VegieBart Inc., copyright 1991.
Re: Need DOS batch help!
Author: Kevin Grover
Date: Wed, 12 Aug 1992 17:48
Date: Wed, 12 Aug 1992 17:48
25 lines
1649 bytes
1649 bytes
In article <92225.09262732BFPQ3@CMUVM.CSV.CMICH.EDU>, Nathan Owen <32BFPQ3@CMUVM.CSV.CMICH.EDU> writes: ) Organization: Central Michigan University ) Date: Wednesday, 12 Aug 1992 09:26:27 EDT ) From: Nathan Owen <32BFPQ3@CMUVM.CSV.CMICH.EDU> ) Subject: Need DOS batch help! ) ) I having a problem writing a batch file. I need a batch file which will go ) to a c:Temp directory and delete every file in the directory except for ) a file named gest.bat. The batch must be written in such a way they the ) user will not get a message asking Yes/No (Y/N) in response to deleting ) the files , which limits your use of wildcard deletes like del *.*. ) If your using 4DOS/NDOS you can use: except (C:\233Temp\gest.bat) del /q/y c:\233Temp\*.* /y forces Y (i.e. or are not asked if your sure) /q means quite mode (i.e. no info on files being deleted) -- -------------------------------------------------------------------------- Kevin O. Grover | UNLV Computer Science and Electrical Engineering grover@isri.unlv.edu | ISRI - Information Science Research Institute CServe: [73627,1677] | 4505 S. Maryland Parkway, Las Vegas NV 89154-1017
Re: Need DOS batch help!
Author: Jeff Miller
Date: Wed, 12 Aug 1992 20:52
Date: Wed, 12 Aug 1992 20:52
19 lines
1219 bytes
1219 bytes
This might be cheating, and I'm doing it from the top of my head, but... DEL_TEMP.BAT: @ECHO OFF c: cd \TEMP ATTRIB +r GEST.BAT ECHO Y | DEL *.* ATTRIB -r GEST.BAT cd \ Note that this assumes ATTRIB is in the path, and that the "ECHO" line works...I'm pretty sure it does. -- _____________________________________________________________________________ | | | "Nuke the unborn gay whales!" | millerje@cs.colostate.edu | Jeff Miller | |_____________________________________________________________________________|
Re: Need DOS batch help!
Author: Nick FitzGerald, CSC, Uni. of Ca...
Date: Thu, 13 Aug 1992 01:00
Date: Thu, 13 Aug 1992 01:00
57 lines
2854 bytes
2854 bytes
In article <1992Aug12.141526.25165@athena.mit.edu>, chanh@athena.mit.edu (Chanh N. Vuong) writes: > In article <92225.09262732BFPQ3@CMUVM.CSV.CMICH.EDU> Nathan Owen <32BFPQ3@CMUVM.CSV.CMICH.EDU> writes: >>I having a problem writing a batch file. I need a batch file which will go >>to a c:\Temp directory and delete every file in the directory except for >>a file named gest.bat. The batch must be written in such a way they the >>user will not get a message asking Yes/No (Y/N) in response to deleting >>the files , which limits your use of wildcard deletes like del *.*. > > DEL_TEMP.BAT: > @echo off > c: > cd \ > cd temp > md tmp > copy gest.bat tmp > for %%a in (*.*) do del %%a > copy c:\temp\tmp\gest.bat . > del c:\temp\tmp\gest.bat > rd tmp > cd \ I'd add a bit of error checking to make sure the tmp dir is actually created. e.g. if not exist tmp\nul goto :md_failed (With some versions of DOS you may have to put a colon after the device name - "nul:" - I'm getting a bit hazy on this.) (NOTE: The "if exist" test above won't work on at least some NetWare drives. Regardless of how ficticious a directory name you give, you will be told that the file exists. You also can't use this type of test on a NetWare drive to tell if you have read or filescan access to a dir - if you test for the existence of any of the DOS device psuedo files regardless of the directory structure and your access rights, "if exist" returns true. I've never seen this "feature" mentioned anywhere before - surely I'm not the first to discover it!) Also check that gest.bat copied OK before deleting all the files in the \temp dir and again before deleting the version in tmp. There are other checks you could make as well - depends on how bomb-proof you want to make it and on who will be using it. Nathan's claim that you won't be able to use "del *.*" is incorrect. Try the following instead of Chanh Vuong's elegant "for..." line: echo y >y.dat del *.* <y.dat >nul From some experience I'd expect the above to execute faster if more than 3 or 4 files are being deleted. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Nick FitzGerald, PC Applications Consultant, CSC, Uni of Canterbury, N.Z. n.fitzgerald@csc.canterbury.ac.nz (64)(3) 642-337 Voice, 642-332 FAX
Re: Need DOS batch help!
Author: Stig Venaas
Date: Thu, 13 Aug 1992 09:55
Date: Thu, 13 Aug 1992 09:55
53 lines
1907 bytes
1907 bytes
In article <1992Aug12.141526.25165@athena.mit.edu> chanh@athena.mit.edu (Chanh N. Vuong) writes: >In article <92225.09262732BFPQ3@CMUVM.CSV.CMICH.EDU> Nathan Owen <32BFPQ3@CMUVM.CSV.CMICH.EDU> writes: >>I having a problem writing a batch file. I need a batch file which will go >>to a c:\Temp directory and delete every file in the directory except for >>a file named gest.bat. The batch must be written in such a way they the >>user will not get a message asking Yes/No (Y/N) in response to deleting >>the files , which limits your use of wildcard deletes like del *.*. >> >>Thanx in advance. > >Here goes: > >DEL_TEMP.BAT: >@echo off >c: >cd \ >cd temp >md tmp >copy gest.bat tmp >for %%a in (*.*) do del %%a >copy c:\temp\tmp\gest.bat . >del c:\temp\tmp\gest.bat >rd tmp >cd \ > >*The End* > > +------------------------------------------------------+ > | |\/\/\/| Chanh N. Vuong (aka Cee Vee) | > | | | chanh@athena.mit.edu | > | | (o)(o) (617)225-6302 or x5-6302 | > | C _) | > | | ,___| Hey, like don't eat a cow, man! | > | | / ----------------------------------------------+ > | /____\ VegieBart Inc., copyright 1991. > I think you could use echo y|del *.*>nul instead of messing around with the for command. -- Stig (venaas@siri.unit.no)
Re: Need DOS batch help!
Author: Rich Holland
Date: Thu, 13 Aug 1992 13:22
Date: Thu, 13 Aug 1992 13:22
42 lines
1748 bytes
1748 bytes
chanh@athena.mit.edu (Chanh N. Vuong) writes: >>I having a problem writing a batch file. I need a batch file which will go >>to a c:\Temp directory and delete every file in the directory except for >>a file named gest.bat. The batch must be written in such a way they the >>user will not get a message asking Yes/No (Y/N) in response to deleting >>the files , which limits your use of wildcard deletes like del *.*. >> >DEL_TEMP.BAT: >@echo off >c: >cd \ >cd temp >md tmp >copy gest.bat tmp >for %%a in (*.*) do del %%a >copy c:\temp\tmp\gest.bat . >del c:\temp\tmp\gest.bat >rd tmp >cd \ This one's easier to follow: @echo off cd \temp attrib *.* -r > nul attrib gest.bat +r > nul echo y | del *.* > nul attrib gest.bat -r > nul cd \ It just sets gest.bat to Read-Only, and erases everything else. (The first attrib command makes sure there's no other RO files out there..) If you're in DOS 5.0, you can also kill Hidden/System files easily like this... -- Rich Holland | INTERNET: holland@matt.ksu.ksu.edu 419 Marlatt Hall | BITNET : holland@ksuvm Manhattan, KS 66506 | UUCP : ...rutgers!matt.ksu.ksu.edu!holland "Jesus saves...but Gretzky gets the rebound! He shoots! He scores!!"
Re: Need DOS batch help!
Author: Bob Mathews
Date: Thu, 13 Aug 1992 22:13
Date: Thu, 13 Aug 1992 22:13
16 lines
1242 bytes
1242 bytes
chanh@athena.mit.edu (Chanh N. Vuong) writes: >In article <92225.09262732BFPQ3@CMUVM.CSV.CMICH.EDU> Nathan Owen <32BFPQ3@CMUVM.CSV.CMICH.EDU> writes: >>I having a problem writing a batch file. I need a batch file which will go >>to a c:\Temp directory and delete every file in the directory except for >>a file named gest.bat. The batch must be written in such a way they the >>user will not get a message asking Yes/No (Y/N) in response to deleting >>the files , which limits your use of wildcard deletes like del *.*. > >Here goes: [suggested batch file deleted] It'd be a lot easier to just change the attribute of gest.bat to read-only. Use attrib +r gest.bat or something like that. If you don't have DOS Help!, you need it. swehtam bob
Re: Need DOS batch help!
Author: Glenn Forbes Larratt
Date: Mon, 17 Aug 1992 17:48
Date: Mon, 17 Aug 1992 17:48
28 lines
1625 bytes
1625 bytes
In article <92225.09262732BFPQ3@CMUVM.CSV.CMICH.EDU> Nathan Owen <32BFPQ3@CMUVM.CSV.CMICH.EDU> writes:
>I having a problem writing a batch file. I need a batch file which will go
>to a c:Temp directory and delete every file in the directory except for
>a file named gest.bat. The batch must be written in such a way they the
>user will not get a message asking Yes/No (Y/N) in response to deleting
>the files , which limits your use of wildcard deletes like del *.*.
>
If you get, by anonymous ftp to wsmr-simtel20.army.mil:
"PD1:<MSDOS.PCMAG>VOL5N09.ARC",1,10219,8,900219,"PC Magazine: NO"
You can then write a batch file thus:
echo off ("@echo off" for DOS 3.30+)
c:
cd \233temp
echo y | no gest.bat del *.* > nul
cd \
What NO does, BTW, is to flag all files matching its first argument as
hidden, then execute the remainder of its command tail as a new command line.
--
===/| Glenn Forbes Larratt | CRC OCIS | "Quid pro quo, |/
==/| glratt@rice.edu (Internet) | Rice University | Clarice." |/=
=/| GLRATT@RICEVM1 (Bitnet) |=================| - The Silence |/==
/| The Lab Ratt (not briggs :-) | Neil Talian? | of the Lambs |/===
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads