Rid
A File Deleter
Paul W. Carlson
If you frequently find yourself deleting files to obtain more space on your disks, you'll appreciate this machine language program that takes the drudgery out of the process. "Rid" is written for the IBM PC/PCjr and compatibles with BASIC and version 2.0 or higher of PC-DOS or MS-DOS. Cartridge BASIC is required for the PCjr.
There is no way around the problem of disks becoming cluttered with unwanted files. How does this happen? Here are a few contributing causes:
- Most text editors and word processors automatically make backup copies so you can recover accidental (or intentional) deletions.
- Programmers often save different versions of a program as they work.
- Some compilers and assemblers create intermediate files.
- Files with time-sensitive information eventually become out-of-date.
With a collection of unnecessary files on your disk, you may have trouble locating the ones you really need. "Rid" is a program that allows you to quickly and safely delete all unwanted files from your floppy or hard disk.
Normally, deleting the unwanted files on a floppy disk (or in the subdirectory of a hard disk) is a dull, time-consuming chore in which typing mistakes can spell disaster. It's all too easy to type DEL BATFILE. BAT instead of DEL BATFILE. BAK or DEL VERSION4. BAS instead of DEL VERSION3. BAS. If you need to delete many files, you may use the wildcards * and? to speed up deleting files with similar names. Unfortunately, using wildcards can easily result in the unintentional deletion of files.
Rid takes a completely different approach. To make the chore as pleasant as possible, it displays the names of all your files on the screen, allowing you to easily select and delete them.
Type in the BASIC program "Rid Creator." Since it creates a machine language file that will perform disk access, be sure to use the IBM Proofreader program, found elsewhere in this issue, to enter it. Be sure to save a copy to disk, but don't use the name RID.COM—that name is reserved for the machine language program that will be created later.
To start the program, type RUN. You're asked to choose between a hard disk and floppy disk version of the program. If you enter F for floppy, the program creates a version of RID.COM that allows you to change disks in the active drive before the directory is read and displayed. If you enter H, the program creates a version of RID.COM that immediately displays the current directory. If you're going to be using Rid with both floppy and hard disks, choose F. After you enter your preference, the program will create a program file named RID.COM. Hard disk users should put a copy of RID.COM in the same directory that contains the other DOS commands that are loaded from disk (the nonresident external commands such as FORMAT, DISKCOPY, and so on), or in any other directory that is included in the DOS search path. Floppy disk users should put a copy of RID.COM on their working copy of the system disk.
A New DOS Command
RID.COM works just like any other DOS command. First, be sure to set the active drive to the drive that will hold the disk with the files you wish to delete. Then, enter RID at the DOS prompt, preceded by the drive designation of the disk containing RID.COM, if RID.COM is in a drive other than the active drive. If you created the version of RID.COM for floppy disks, you'll be told to insert a disk in the active drive. If the disk you want to use is not in the drive, place it there and press a key to continue. The active drive and current directory are displayed at the top of the screen, followed by a list of the first 100 files. RID.COM will let you delete only those files found among the first 100 in a directory, but this should seldom, if ever, be a limiting factor.
After the files are displayed, a line of instructions explaining the keyboard controls appears at the bottom of the screen. Notice that one of the files is highlighted. Use the arrow keys to move the highlight from one filename to another. When you press the D key (upper-or lowercase), the chosen file will be deleted immediately from the disk, and the name of the file will disappear from the screen. You can now move the highlight to the name of the next file to be deleted. Be very careful to delete the correct file or files. If you make a mistake and delete a file that you wanted to keep, you may be able to recover your lost files with a disk utility program.
To exit RID.COM and return to DOS, press the Escape key. Once you've become accustomed to using RID.COM, you'll wonder how you got along without it.
Rid Creator
For instructions on entering these programs, please refer to "COMPUTE!'s Guide to Typing In Programs" elsewhere in this issue.
NA 1 ‘ program to create RID.COM NA 2 ‘ Copyright 1987 Compute! Publications, Inc. IK 3 ‘ All Rights Reserved. GI 4 CLS:PRINT "COPYRIGHT 1987" : PRINT "COMPUTE! PUBLICATIONS, INC." DC 5 PRINT "All RIGHTS RESERVED.&lrdquo; KE 6 FOR ZZ = 1 TO 1500:NEXT:CLS MP 10 INPUT"Create RID.COM for Hard or Floppy disk (H Or F)";D$ LM 20 IF D$ = "H" OR D$ = "h" THEN D = &H7A:GOTO 50 NE 30 IF D$ = "F" OR D$ = "f" THEN D = &H6E:GOTO 50 FF 40 GOTO 10 DN 50 OPEN "RID.COM" FOR OUTPUT AS 1 PJ 60 PRINT#1, CHR$ (&HE9); CHR$ (D); CHR$(&H8); HL 70 FOR N = 1 TO 1927:PRINT#1,CH R$ (O); :NEXT FP 80 T = 0:FOR J = 1 TO 910:READ A$: N = VAL ("&H" + A$) FG 90 T = T + N:PRINT#1,CHR$ (N);: NEXT: CLOSE 1 NI 100 IF T = 84241! THEN PRINT "RID.COM SUCCESSFULLY CREATED!": END KH 110 PRINT CHR$ (7); "****** ERROR IN DATA STATEMENTS *****": END LN 120 DATA 00, 00, 00, 00, 00, 00, 2A, 2E, 2A, 00 JM 130 DATA 0A, 0A, 0D, 49, 6E, 73, 65, 72, 74, 20 GK 140 DATA 64, 69, 73, 6B, 20, 69, 6E, 20, 61, 63 GB 150 DATA 74, 69, 76, 65, 20, 64, 72, 69, 76, 65 PN 160 DATA 2C, 20, 74, 68, 65, 6E, 20, 0A, 0D, 20 KA 170 DATA 20, 20, 70, 72, 65, 73, 73, 20, 61, 6E DL 180 DATA 79, 20, 6B, 65, 79, 20, 74, 6F, 20, 63 NH 190 DATA 6F, 6E, 74, 69, 6E, 75, 65, 2E, 2E, 2E CB 200 DATA 24, 44, 45, 4C, 45, 54, 49, 4E, 47, 20 FF 210 DATA 46, 49, 4C, 45, 53, 20, 46, 52, 4F, 4D LL 220 DATA 20, 20, 20, 3F, 3A, 5C, 24, 44, 69, 73 GG 230 DATA 6B, 20, 61, 63, 63, 65, 73, 73, 20, 65 LF 240 DATA 72, 72, 6F, 72, 20, 2D, 20, 70, 72, 65 LC 250 DATA 73, 73, 20, 61, 6E, 79, 20, 6B, 65, 79 MP 260 DATA 20, 74, 6F, 20, 63, 6F, 6E, 74, 69, 6E BK 270 DATA 75, 65, 2E, 2E, 2E, 0A, 0A, 0D, 24, 0A KL 280 DATA 0A, 0D, 20, 20, 20, 20, 20, 20, 20, 20 AE 290 DATA 20, 55, 73, 65, 20, 61, 72, 72, 6F, 77 EK 300 DATA 20, 6B, 65, 79, 73, 20, 74, 6F, 20, 6D KC 310 DATA 6F, 76, 65, 2C, 20, 5B, 44, 5D, 20, 74 MA 320 DATA 6F, 20, 64, 65, 6C, 65, 74, 65, 20, 66 PA 330 DATA 69, 6C, 65, 73, 2C, 20, 5B, 45, 73, 63 CF 340 DATA 5D, 20, 74, 6F, 20, 71, 75, 69, 74, 2E KJ 350 DATA 24, 8D, 16, 94, 08, B4, 09, CD, 21, B4 JD 360 DATA 07, CD, 21, B4, 0F, CD, 10, A2, 43, 07 EC 370 DATA 88, 3E, 44, 07, B4, 03, BA, 3E, 44, 07 OH 380 DATA CD, 10, 88, 2E, 45, 07, 88, 0E, 46, 07 JK 390 DATA B4, 08, CD, 10, 88, 26, 4F, 07, BB, 00 PN 400 DATA 06, B7, 07, 33, C9, BA, 4F, 18, CD, 10 NJ 410 DATA B8, 00, 02, 33, DB, 33, D2, CD, 10, B8 JM 420 DATA 00, 00, A0, 43, 07, 3C, 07, 74, 02, B0 BI 430 DATA 02, CD, 10, C6, 06, 47, 07, 00, B4, 19 EJ 440 DATA CD, 21, 04, 41, 8D, 36, DB, 08, 83, C6 JB 450 DATA 16, 88, 04, B4, 47, 8D, 36, 50, 08, B2 ND 460 DATA 00, CD, 21, 8D, 36, 50, 08, 8A, 04, 46 BA 470 DATA 3C, 00, 75, F9, 4E, B0, 0A, 88, 04, 46 CC 480 DATA 88, 04, B0, 0D, 46, 88, 04, 46, B0, 24 EJ 490 DATA 88, 04, B4, 09, 8D, 16, DB, 08, CD, 21 AB 500 DATA 8D, 16, 50, 08, CD, 21, 8D, 16, 50, 07 LA 510 DATA B4, 1A, CD, 21, 8D, 3E, 03, 01, B4, 4E LC 520 DATA 8D, 16, 90, 08, B9, 00, 00, CD, 21, 72 EA 530 DATA 3F, FE, 06, 47, 07, B9, 11, 00, 8D, 1E OO 540 DATA 50, 07, 83, C3, 1E, 49, BA, 17, 80, FA BK 550 DATA.00, 74, 0A, 88, 15, 47, B4, 02, CD, 21 OO 560 DATA 43, EB, EE, B4, 02, B2, 20, CD, 21, 47 OC 570 DATA E2, FB, 80, 3E, 47, 07, 64, 75, 03, EB BP 580 DATA 40, 90, BD, 16, 90, 08, B4, 4F, CD, 21 GN 590 DATA 72, 35, EB, C1, 8D, 16, F5, 08, B4, 09 DE 600 DATA CD, 21, B4, 07, CD, 21, B4, 00, A0, 43 HP 610 DATA 07, CD, 10, B4, 05, A0, 44, 07, CD, 10 EC 620 DATA 8A, 2E, 45, 07, 8A, 0E, 46, 07, CD, 10 PL 630 DATA B8, 00, 06, 33, C9, BA, 4F, 18, 8A, 3E IL 640 DATA 4F, 07, CD, 10, C3, 8D, 16, 29, 09, B4 OP 650 DATA 09, CD, 21, C6, 06, 4D, 07, 02, C6, 06 EH 660 DATA 4C, 07, 02, C6, 06, 4B, 07, 00, C6, 06 MC 670 DATA 4A, 07, 00, C6, 06, 49, 07, 00, E8, 3A JD 680 DATA 01, B4, 07, CD, 21, 3C, 00, 74, 0D, 3C LA 690 DATA 1B, 74, A9, 0C, 20, 3C, 64, 75, EE, E9 MJ 700 DATA B6, 00, B4, 07, CD, 21, 3C, 48, 75, 21 MG 710 DATA 80, 3E, 4D, 07, 03, 72, DC, 8A, 0E, 4D JM 720 DATA 07, FE, C9, 88, 0E, 4C, 07, BA, 0E, 49 BN 730 DATA 07, 80, E9, 05, 88, 0E, 48, 07, E8, FE BN 740 DATA 00, EB, C2, 3C, 4B, 75, 20, 80, 3E, 4B JF 750 DATA 07, 00, 74, B7, 8A, 0E, 4B, 07, FE, C9 HK 760 DATA 88, 0E, 4A, 07, BA, 0E, 49, 07, FE, C9 JG 770 DATA 88, 0E, 48, 07, E8, DA, 00, EB, 9E, 3C OG 780 DATA 50, 75, 2A, BA, 16, 47, 07, 2A, 16, 49 EP 790 DATA 07, 80, FA, 05, 77, 02, EB, 8B, BA, 0E EA 800 DATA 4D, 07, FE, C1, 88, 0E, 4C, 07, 8A, 0E CI 810 DATA 49, 07, 80, C1, 05, 88, 0E, 48, 07, EB QK 820 DATA AD, 00, E9, 70, FF, 3C, 4D, 74, 03, E9 NL 830 DATA 69, FF, 80, 3E, 4B, 07, 04, 75, 03, E9 EA 840 DATA SF, FF, 8A, 16, 47, 07, 2A, 16, 49, 07 LD 850 DATA 80, FA, 01, 77, 03, E9, 4F, FF, 8A, 0E QM 860 DATA 4B, 07, FE, C1, 88, 0E, 4A, 07, 8A, 0E EG 870 DATA 49, 07, FE, C1, 88, 0E, 48, 07, E8, 72 FE 880 DATA 00, E9, 35, FF, E8, 1F, 00, 8A, 04, 3C HA 890 DATA 20, 75, 03, E9, 29, FF, 8B, D6, B4, 41 BE 900 DATA CD, 21, B0, 20, B9, 0C, 00, 88, 04, 46 FC 910 DATA E2, FB, E8, 50, 00, E9, 13, FF, A0, 49 KC 920 DATA 07, B4, 00, D1, E0, D1, E0, D1, E0, D1 HI 930 DATA E0, BE, 03, 01, 03, F0, C3, 8A, 16, 4B QO 940 DATA 07, D0, E2, D0, E2, D0, E2, D0, E2, 8A LK 950 DATA 36, 4D, 07, B7, 00, B4, 02, CD, 10, C3 GO 960 DATA E8, D3, FF, E8, E3, FF, B7, 00, BA, 1E LD 970 DATA 4E, 07, B9, 01, 00, B4, 09, BA, 04, 46 DH 980 DATA 3C, 00, 74, 0A, CD, 10, FE, C2, B4, 02 KI 990 DATA CD, 10, EB, ED, C3, C6, 06, 4E, 07, 07 NM 1000 DATA E8, D5, FF, C6, 06, 4E, 07, 70, A0, 4C OK 1010 DATA 07, A2, 4D, 07, A0, 4A, 07, A2, 4B, 07 BH 1020 DATA A0, 48, 07, A2, 49, 07, E8, BB, FF, C3