home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware 1 2 the Maxx
/
sw_1.zip
/
sw_1
/
EDITORS
/
CPT_102.ZIP
/
RMLIST.DOC
< prev
next >
Wrap
Text File
|
1992-03-20
|
12KB
|
301 lines
┌───────────────────────────────────────────────────────┐
│ │
│ │
│ │
│ │
│ RMLIST.BAT │
│ │
│ │
│ Automated file deletion │
│ │
│ │
│ February 16, 1992 │
│ │
│ │
│ │
│ │
│ │
└───────────────────────────────────────────────────────┘
If you're a graphics nut, like me, then more likely than not
you've moved large numbers of files off of your hard drive onto
floppy disks, to free up space on the hard drive. If you're
dealing with several hundred files or even just a few large ones,
removing the files from the hard drive by typing the names in one
at a time can be a real chore. And you can't just do "del *.*"
if you didn't get them all copied. So you're in for a long,
boring, typing session which is probably why you let that many
accumulate, in the first place (other kinds of nuts have this
problem too). Well, ya don't have to do it that way any more
because now you can automate the file removal with RMLIST.BAT.
RMLIST.BAT is a simple batch file that controls some
powerful system utilities that will take the drudgery out of that
file removal job and make you grin (guaranteed). In reference to
the listings and descriptions that follow, some preliminary
explanation may be in order (or not). You will notice the path
names in RMLIST.BAT. I prefer a short path in my system setup
and perform most operations using batch files that have the
necessary file path information in them. Doesn't have to be done
that way but, that's the way I do it. This listing is of the
actual batch file that I use, hence, the file paths. C:\batch is
where I keep all of my batch files (it's in the system path).
C:\batch\tmp is the place where I do garbage work like THIS.
There's never anything of value in there and so I don't worry
about corrupting something.
Here's the numbered listing for RMLIST.BAT, an explanation of how
to use it and what it does:
1: DIR %1: >C:\BATCH\TMP\FILES.TXT
2: CUTPASTE C:\BATCH\TMP\FILES.TXT C:\BATCH\TMP\FILES.BAT
-f="DEL^" 1-8 -f="." 10-12
3: EDLIN C:\BATCH\TMP\FILES.BAT < C:\BATCH\COMMANDS.LST
4: CALL C:\BATCH\TMP\FILES.BAT
5: DEL C:\BATCH\TMP\FILES.*
You should be in the directory where the files you are
transferring to floppy disk are located. If you aren't, CD to
that directory. Then, copy some files to media in your floppy
disk drive. If you want to copy everything in the directory just
use "copy *.* a:". "a" being the floppy drive you are copying
to. If you don't want to copy everything in the directory, then
sit there and type 'em in by hand (we're trying to eliminate all
this typing, remember?). The other stuff will be safe,
RMLIST.BAT will only remove the files you have copied to the
floppy drive. When you have filled up the floppy disk, the
system will display an error message like: "insufficient disk
space" and report how many files were SUCCESSFULLY copied. When
the copy on the last file failed, the directory did not get
updated so that file will not list and therefore will not be
removed by RMLIST.BAT.
When you call RMLIST.BAT, the command line should be:
rmlist [drive designator]
drive designator being the floppy drive you just copied the files
to (our example is using "a"). DO NOT type in the colon after
the drive letter. If you do, RMLIST.BAT will fail and remove
nothing. You can change the batch file if you find this hard to
get used too. Just edit out the first colon in line one of
RMLIST.BAT. Then you can do that unnecessary key press for the
colon.
Note: The floppy disk you just copied to, must be in the
designated disk drive for this to work.
So... you've just typed in "rmlist a". Now, press ENTER, lean
back, and experience instant gratification, while the COMPUTER
does the work (that IS what they're supposed to do).
OKAY - COOL........ SO WHAT HAPPENED? (explain the process)
RMLIST.BAT
line 1: reads the directory of the floppy in the designated
drive (in this case "a") and writes that directory
listing to the file "c:\batch\tmp\files.txt". The
listing will be similar to this:
Volume in drive B is GRAPHICS
Directory of B:\
MOONWLK PCX 31274 02-07-91 9:06p
AUSSIE PCX 50177 11-14-88 7:44p
CV1-50C PCX 6413 09-10-89 5:36a
CV1-54C PCX 3657 09-10-89 5:36a
( LOTS MORE STUFF LISTED HERE )
CV2-33T PCX 9658 10-28-89 9:56p
CV3-02M PCX 8858 09-10-89 5:37a
CV3-05T PCX 7516 09-10-89 5:37a
CV3-07M PCX 13660 09-10-89 5:37a
CV3-08M PCX 12666 09-10-89 5:37a
21 file(s) 349724 bytes
2048 bytes free
line 2: calls the program "CUTPASTE.EXE" (if you're reading
this, you should have this program). This program
should be kept in a directory in your system path so
that you can call it from anywhere. CUTPASTE reads the
"c:\batch\tmp\files.txt" file, strips off everything
but the file names, pastes in the text: "DEL^" and a
period (.) between the file name and it's extension and
writes it back out to the file
"c:\batch\tmp\files.bat". The circumflex character (^)
is important as a place holder (as you will see). When
CUTPASTE is finished, "c:\batch\tmp\files.bat" will
look like this:
DEL^ Volume .n d
DEL^ Directo.y o
DEL^MOONWLK .PCX
DEL^AUSSIE .PCX
DEL^CV1-50C .PCX
DEL^CV1-54C .PCX
( LOTS MORE STUFF LISTED HERE )
DEL^CV2-33T .PCX
DEL^CV3-02M .PCX
DEL^CV3-05T .PCX
DEL^CV3-07M .PCX
DEL^CV3-08M .PCX
DEL^ 2. fi
DEL^ .
line 3: calls "EDLIN" (the MICROSOFT system line editor) to
take out the spaces between the file names and the
period (.) that separates the file name extensions
(this is why we put the circumflex (^) in the records).
Edlin then removes the first two lines from the listing
and the last two lines from the listing (because they
are garbage, not valid file names). And last but not
least, EDLIN replaces all the circumflex characters
with space characters so that each line looks like
this:
DEL CV2-33T.PCX
DEL CV#-02M.PCX (etc.... etc.... etc....)
Where did EDLIN get the instructions to do all this?
From a command script in the c:\batch directory, called
"commands.lst" (betcha didn't know you could do that).
EDLIN is a great tool. Too bad it's not documented
better. Anyway.... so now you've created a batch file
that can be executed.
line 4: executes the batch file created in line three, as a
child process and deletes all the files on (we're
presuming) drive c:, that were copied to drive a:.
line 5: The child process in line 4 has terminated and
RMLIST.BAT cleans up by deleting the work files and the
batch file "files.bat", in the c:\batch\tmp directory
using the command "DEL c:\batch\tmp\files.*"
( WHEW! )
All done. So now you can repeat the process with a new floppy
disk. Copy files, run RMLIST.BAT, copy files, run RMLIST.BAT.
You'll have that old hard drive cleaned up in no time!
And when you get done, it would be a good idea to run MICROSOFT's
"chkdsk" program to cleanup any fragmentation that may have
resulted from all that activity. BUT, please read the manual
before you run it as certain conditions make running it
unadvisable.
The file: "c:\batch\commands.lst" contains instructions for
edlin to run unattended. The instructions are cryptic if your
not familiar with edlin and not much more easily understood by
many who ARE familiar with it. The following is a listing (with
line numbers) of that command script and an explanation:
1: #
2: -1
3:
4: 1,r ^Z (the ^Z ends this line)
5: #
6: -1
7:
8: 1,r^^Z (there is a SPACE character at the end of this
line)
9: #
10: -1d
11: -1d
12: 1,2d
13: e
line 1: tells edlin to go to the end of the file
line 2: sets the pointer to the last line of the file
line 3: is blank, to simulate a press of the ENTER key
line 4: tells edlin to replace all spaces with nothing, from
line 1 to the end of the file
line 5: tells edlin to go to the end of the file
line 6: sets the pointer to the last line of the file
line 7: is blank, to simulate a press of the ENTER key
line 8: tells edlin to replace the circumflex character (^)
with a space, from line 1 to the end of the file. The
space character follows the "^Z" character and is
invisible (naturally). The "^Z" character is generated
with the F6 key.
line 9: tells edlin to go to the end of the file
line 10: tells edlin to set the pointer to the last line and
delete the line
line 11: tells edlin to set the pointer to the last line and
delete the line
line 12: tells edlin to delete lines 1 and 2
line 13: tells edlin to quit and save the edit session
Now, if you list commands.lst to the screen or printer, all of
the characters shown in this listing will not appear, but, they
are there. This is because some of the characters (^Z) are
mistaken for END OF FILE MARKERS. If you feel the need to load
this file into an editor, use EDLIN with the /B switch.
BEGGING FOR BUCKS
Hey! You can't call this shareware! No, not by any stretch
of the imagination. It's just a technique I devised that has
saved me lots of time and I wanted to share it with you. If you
like it, use it. Pass it around to your friends and co-workers.
Upload it to other BBS. I only ask that you keep the package
intact. All of the files are important and one of them is not a
"freebee".
Correspondence regarding RMLIST.BAT and/or the rest of this
package is most welcome and should be directed to:
Bill Leckband
1628 S. Everett Place
Kennewick, Wa. 99336
MICROSOFT is a registered trademark of Microsoft Corp.
CHKDSK and EDLIN are copyrighted products of Microsoft Corp.