home *** CD-ROM | disk | FTP | other *** search
- @echo off
- :
- : DFC Dave's Floppy Cataloguer Version 1.31
- :
- : original program TFC - Tobi's Floppy Cataloguer Version 1.0
- : (C) 4-01-92, 2:31 PM by Tobi Oetiker
- : (no joke !)
- :
- : This program is released into the Public Domain.
- : Feel free to make changes but don't remove my name and address.
- : Let me know if you have any useful enhancements or if you find errors ...
- :
- : (C) 3 Oct 92 by David Frey & Itamar-Even Zohar
- :
- : P.S: ^^^^ means: adapt to your needs
- :
- : Revision changes:
- : -----------------
- : Ver 1.1: . highlighted menu
- : . adapted to 4DOS 4.01 (unset /q etc.)
- : . sort of %DISKSDB incorporated.
- : Ver 1.2: . Itamar Even-Zohar's Findall has been added.
- : . Some minor corrections have been made.
- : Ver 1.3: . Corrections suggested by Itamar Even-Zohar's have
- : been implemented.
- : . Customizing is now done by setting environment variables,
- : so you have to edit DFC.BTM only at one place.
- : Ver 1.31 . ANSI detection implemented, you need not to install ANSI.SYS,
- : although it's recommended when using directory colorization.
-
- cls
- setlocal
- unalias *
-
- set fg=%_fg
- set bg=%_bg
-
- iff %@index[%1,?] ge 0 .or. %@index[%1,help] ge 0 .or. %1 == h .or. %1 == /h .or. %1 == -h then
- gosub help
- goto /i exit
- endiff
-
- echo DFC - Dave's File Cataloguer by David Frey Version 1.31 10-NOV-92
- echo and Itamar Even Zohar
- echo based on TFC by Tobi Oetiker (oetiker@iis.ethz.ch)
- echo.
-
- iff %_env LT 170 then
- if %monitor == color color bright %fg on %bg
- echos ** ABORTED
- if %monitor == color color %fg on %bg
- text
-
- You need approx. 170 bytes of free environment space after DFC
- has started. (depends on your configuration). Use
-
- unset var
-
- to make space or raise the environment value in your 4dos.ini file.
-
- * var stands for any environement variable. You get a list of your
- variables by typing `set` at the command prompt. Using the command
- `memory` you can check how much space is left.
- endtext
- quit
- endiff
-
- :customize
- :^^^^^^^^^
- :
- : In older versions of DFC (previous 1.3) you had to edit DFC.BTM at
- : various places to get a pleasant appearance (favourite editor, list,...).
- : This isn't necessary anymore; set the appropriate environment variables
- : below.
- :
- : set edt=%@search[<your favorite editor>]
- : set desced=%@search[<a 4DOS description editor>]
- : set ff=%@search[<a file finder>]
- : set grep=%@search[< a GREP grogram (GNU's grep preferred>]
- : set list=<a file lister - for example 4DOS internal "list">
- :
- : * Use GNU's grep whenever possible, or you may have to change the
- : command line switches...
- : * The directory where your application resides in will be determined
- : by 4DOS' %@search, that means that your application must be included
- : in the PATH!
- : (Of course, there is the possibility to write the whole path e.g.
- : C:\TOOLS\tpe.exe, but I think that is not a good idea. Why ? I, for
- : myself, have copied the files I often use to a RAM-disk - this
- : minimizes hard disk accesses and speeds up your work. By using
- : %@search, DFC will find the versions on the RAM-disk first. If
- : you have removed your RAM disk - to save memory - DFC will still find
- : the versions on your hard disk. (Assuming that your path is set to
- : <RAM-disk>;C:\...)
-
- : my configuration:
- :
- set edt=%@search[tpe.exe]
- set desced=%@search[4desc.exe]
- set ff=%@search[ff.exe]
- set grep=%@search[grep.exe]
- set list=list
- : (Turbo Power's Public Domain editor, my own 4DOS Description Editor and
- : file finder, 4DOS' built in list, and GNU's GREP (recommended!))
-
- : Itamar's configuration:
- :
- : set edt=%@search[ped.exe]
- : set desced=%@search[4edit.exe]
- : set ff=%@search[whereis.exe] %& -o"&f &m" -a
- : set grep=%@search[grep]
- : set list=%@search[list]
- : (Bob Foley's editor, 4edit, Keith Ledbetters SST, GNU's grep and list )
-
- :check_temp
- :
- : If "temp" is not defined, it will be defined as your "last disk"
- : (C:, or D:, etc.). If it *is* defined, but no trailing backslash is
- : found, then it will be added. This will also add a trailing backslash
- : to the 'temp" just defined (it will then become C:\, or D:\, etc.).
-
- iff "%temp"=="" then set temp=%_lastdisk:\
- elseiff "%@substr[%temp,0,-1]" != "\" then set temp=%temp\
- endiff
-
- :check_ansi
- iff %_ansi == 1 then
- set clrtoeol=e[K
- else
- set clrtoeol= %@chr[13]
- endiff
-
- :check_diskdb
- :
- : Sets %DISKDB to the directory where DFC.BTM resides
-
- iff "%diskdb" == "" then
- set diskdb=%@path[%@search[dfc.btm]]disks.db
- : Change file name as necessary ^^^^^^^^
-
- iff "%@search[%diskdb]" == "" then
- echo Disk database ("%diskdb") not found!
- echo.
- quit
- endiff
- endiff
-
- :setup_and_search_GREP
- set tempdiskdb=%temp%%@name[%diskdb].%@ext[%diskdb]
- iff "%grep" ne "" then ^ set tempfile=%temp%dfctemp.$$$ ^ endiff
-
- iff "%1" == "scan" then
- set disk=%2
- set oldlabel=%@label[%disk]
-
- :waitfordisk
- :
- : Wait for a disk to be inserted.
-
- echos %@char[13]> please INSERT disk and press any key... or ESC to EXIT%clrtoeol%
- unset /q t
- inkey %%t >& NUL:
- if %t == %@char[27] goto /I exit
- if %@ready[%disk] == 0 goto /I waitfordisk
- gosub scan
-
- :change
- echos %@char[13]=> please REMOVE disk ... or press ESC to EXIT%clrtoeol%
- unset /q t
- inkey %%t >& NUL:
- iff %t != %@char[27] then ^ goto /I waitfordisk ^ endiff
- elseiff "%1" == "find" .or. "%1" == "get" then
- set file=%2
- gosub get
- elseiff "%1" == "compare" .or. "%1" == "findall" then
- set file=%2
- gosub findall
- else
-
- :menuloop
-
- iff %_monitor == mono then
- echo 1) Scan disk
- echo 2) Find an entry
- echo 3) Compare entries on harddisk with your disk database.
- echo 7) Sort database '%diskdb' alphabetically
- echo 8) Edit database '%diskdb'
- echo 9) View database '%diskdb'
- echo ?) Help screen
- echo.
- echo 0) Exit
- else
- echos 1)
- color bright white on %bg ^ echos S ^ color %fg on %bg
- echo can disk.
- echos 2)
- color bright white on %bg ^ echos F ^ color %fg on %bg
- echo ind an entry.
- echos 3)
- color bright white on %bg ^ echos C ^ color %fg on %bg
- echo ompare entries on harddisk with your disk database.
- echos 7) S
- color bright white on %bg ^ echos o ^ color %fg on %bg
- echo rt database '%diskdb' alphabetically.
- echos 8)
- color bright white on %bg ^ echos E ^ color %fg on %bg
- echo dit database '%diskdb'.
- echos 9)
- color bright white on %bg ^ echos V ^ color %fg on %bg
- echo iew database '%diskdb'.
- echos ?)
- color bright white on %bg ^ echos H ^ color %fg on %bg
- echo elp screen
- echo.
- echos 0) E
- color bright white on %bg ^ echos x ^ color %fg on %bg
- echo it
- endiff
- echo.
-
- :dochoice
- inkey /K"0123789SFCOEV?HX[ESC]" Your choice: %%ans
- set ans=%@upper[%ans]
- iff %ans == %@char[27] .or. %ans == 0 .or. %ans == X then goto /i exit
- elseiff %ans == 1 .or. %ans == S then
- inkey /K"ABCDEFGH" Disk drive to scan: (A-%_lastdisk) %%disk
- set disk=%disk:
- set oldlabel=%@LABEL[%disk]
- dir %disk
- echo.
- input /K"YN" Shall the disk be labelled ? (Y/N) %%ans2
- iff %ans2 == y then ^ label %disk ^ endiff
- input /K"YN" Are the descriptions correct ? (Y/N) %%ans2
- iff %ans2 == n then ^ %desced %disk ^ endiff
- input /K"YN" Shall this disk be scanned ? (Y/N) %%ans2
- iff %ans2 == y then
- gosub scan
- echo.
- echo.
- echo The floppy catalog: "%diskdb" is now up to date
- pause
- endiff
- elseiff %ans == 2 .or. %ans == F .or. %ans == G then
- unset /q file
- gosub get
- elseiff %ans == 3 .or. %ans == C then
- unset /q file
- input What file are your searching for ? %%file
- gosub findall
- elseiff %ans == 7 .or. %ans == O then
- echos Sorting %diskdb alphabetically, please wait...
- sort < %diskdb > %tempdiskdb
- del /q %diskdb
- move /q %tempdiskdb %diskdb
- echo done.
- elseiff %ans == 8 .or. %ans == E then %edt %diskdb
- elseiff %ans == 9 .or. %ans == V then gosub list
- elseiff %ans == ? .or. %ans == H then gosub help
- endiff
-
- cls
- echo DFC - Dave's File Cataloguer by David Frey Version 1.31 10-NOV-92
- echo and Itamar Even Zohar
- echo based on TFC by Tobi Oetiker (oetiker@iis.ethz.ch)
- echo.
- goto /i menuloop
- endiff
-
- :exit
- if "%diskdb" != "" .and. "%@descript[%diskdb]" == "" describe %diskdb "updated file database"
-
- if exist %tempfile del /q %tempfile
- if exist %tempdiskdb del /q %tempdiskdb
-
- echo.
- echo Thank you for using DFC ...
- echo.
- color %fg on %bg
- endlocal
- quit
-
- : ---------------------------------- Subroutines
-
- :scan
- :
- : Scans a disk
-
- : When grep is around, remove Info from previous scanning
- : from the Database File
- :
- iff "%grep" ne "" .and. exist %diskdb then
- echos %@char[13]** Removing old entries for "%oldlabel"%clrtoeol%
- %grep -v -i "^%oldlabel" %diskdb > %tempdiskdb
- endiff
-
- :add_data
-
- :
- : ADD DATA FROM DISK TO DATABASE
- :
-
- echos %@char[13]** Adding new entries from Disk "%@label[%disk]"%clrtoeol%
- dir /djmkla:-d-h %disk > %tempfile
- set n=%@lines[%tempfile]
- set l=0
- iff %n gt -1 then
- :echoloop1
- echos %@upper[%@label[%disk]] >> %tempdiskdb
- echos %@substr[ ,0,%@eval[12-%@len[%@label[%disk]]]] >> %tempdiskdb
- echos %_date >> %tempdiskdb
- echo %@line[%tempfile,%l] >> %tempdiskdb
- set l=%@eval[%l+1]
- if %l le %n goto /i echoloop1
- endiff
-
- move /q %tempdiskdb %diskdb
- del /q %tempfile
- return
-
- :get
- :
- : Search for a file in the database.
-
- iff "%file" == "" then
- input What are you searching for: %%file
- endiff
-
- echo.
- echos Searching for: »
- if %_monitor == color color bright white on blue
- echos %file
- if %_monitor == color color %fg on %bg
- echo.
- echo Please wait...
- (echo Disk Scanned File Size Date Time Description ^
- echo ──────────────────────────────────────────────────────────────────────────── ^
- %grep -i "%file" %diskdb) >%tempfile
-
- : The original routine piped the finding to screen via '|list /s'.
- : However, in order to be able to check whether any match was found,
- : a file had to be opened, then 3rd line checked. If '*EOF*' is found
- : in that line, this means that there was no match.
-
- iff %@index[%@line[%tempfile,2],*EOF*] ge 0 then
- echo.
- echo No match found in %diskdb for "%file"
- echo.
- pause
- else
- %list %tempfile
- endiff
- del /q %tempfile
- return
-
- :list
- :
- : List disk database
-
- (echo Disk Scanned File Size Date Time Description ^
- echo ──────────────────────────────────────────────────────────────────────────── ^
- type %diskdb) > %tempfile
- %list %tempfile
-
- : Original line was: (echo ... ^ type %diskdb)|list/s
- : Piping via '|list/s' works only with 4DOS's internal list. In order
- : to use external list programs, a temporary file must be created.
- del /q %tempfile
- Return
-
- :findall
- :
- : By Itamar Even-Zohar (slightly changed by David Frey)
- : Looks for specified files, or a string thereof, using %ff, then searches diskette
- : catalogue and displays results to screen by %list
-
- echo.
- echos Searching for: »
- if %_monitor == color color bright white on blue
- echos %file
- if %_monitor == color color %fg on %bg
- echo «
- echo Please wait...
- <
- (echo.^echo Files found on disk
- echo ──────────────────────────────────────────────────────────────────────────── ^
- %ff %file) >%temp%find.Tmp
-
- (echo.^
- echo Files found in Catalogue of Diskettes: ^
- echo Disk Scanned File Size Date Time Description ^
- echo ──────────────────────────────────────────────────────────────────────────── ^
- %grep -i "%file" %diskdb) >>%temp\find.Tmp
-
- %list %temp%find.tmp
- del /q %temp%find.tmp
- return
-
- :help
- :
- : Shows a help screen.
-
- cls
- if %_monitor == color color bright yellow on %bg
- echo Dave's File Cataloguer by David Frey and Itamar Even Zohar Ver 1.31 10-NOV-92
- echo based on TFC by Tobi Oetiker (oetiker@iis.ethz.ch)
- if %_monitor == color color %fg on %bg
- text
-
- DFC creates and maintains a directory-styled database. The database contains
- information of all the files on the floppies you scan: disklabel, filesize,
- creation date, filename, 4DOS file description and scanning date.
- To use DFC as a floppy cataloging system, label your disks with `LABEL' and
- describe the files on it (or use menu point 1!). It is a good idea to write
- the disk labels on the cover for future recognition...
- If GNU's GREP.EXE (available from Simtel) lives on your system, and you scan
- a floppy which was previously processed, the database entries of the previous
- scan will be replaced by the new ones.
-
- Usage : DFC scan <drive>|find|compare <drive> is the drive you want to scan.
-
- DFC will use the catalog file stored in the environment variable
- "diskdb" or "DISKS.DB" as default, when diskdb is empty.
-
- Example: dfc scan a: --> scan drive a:
- dfc get 4DOS --> search for 4dos.* files
-
- Written by David Frey, Urdorferstrasse 30, CH-8952 Schlieren
- and Itamar Even-Zohar, Tel Aviv University
- Original program and idea by Tobi Oetiker (oetiker@iis.ethz.ch)
- endtext
- echos Gallusstrasse 25, CH-4600 Olten, FAX +41 62 32 61 78
- unset /q ans2
- inkey %%ans2
- return