home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
jambtm02.exe
/
FILE.BTM
< prev
next >
Wrap
Text File
|
1992-11-15
|
5KB
|
131 lines
*REM This batch file is Freeware, free to use and redistribute unmodified *
*REM Jouni Miettunen * jon@stekt.oulu.fi * Oulu * Finland * Europe * 1992 *
REM unixlike file utility. Has more correct guesses than the original one!
REM Timestamp 15-Nov-1992
break on^setlocal^unalias *^if %#==0 .or. "%1"=="-?" goto info
REM Needs some kind of GREP clone, DOS's FIND should be in every machine..
REM I prefer Christopher J. Dunford's FastGREP 1.72 from SIMTEL-20 mirror.
REM Note: when using FIND u must change "%@line[con,0]" to "%@line[con,2]"
REM Note: In future 4DOS versions %@search[find /i] might generate error
REM set TOOL=find/i
set TOOL=fgrep -sx1
iff "%@search[%TOOL]"=="" then^echo Error: Can't find %TOOLn^goto info^endiff
REM "extensio.txt" database of file extensions, set *absolute path* below
REM format: (point)(max three chars)(TAB)(description max 63 char) No commas!
REM .txt text file (ASCII)
set DATA=c:\relax\extensio.txt
iff "%@search[%DATA]"=="" then^echo Error: Can't find %DATAn^goto info^endiff
REM PLAZA sets the description column (16 is 2 TABs), used in 3 places.
set PLAZA=14
REM Get current home directory for recursive listings
set home=%_cwds
REM Did the user give any arguments? Is it argument or a file?
if "%@ascii[%1]" != "45" .or. exist %1 goto over^if %#==1 goto info
:optiot
set index=%@eval[%index+1]^set %@ascii[%@substr[%1,%index,1]]=1
if %index lt %@eval[%@len[%1]-1] goto optiot^shift
iff "%[%@ascii[R]]"=="1" then^set g=global^set h=/qi^endiff
iff "%[%@ascii[a]]"=="1" then^alias for=*for /a-d^if "%h" != "" set h=/qih^endiff
iff "%[%@ascii[*]]"=="1" then^endiff
iff "%[%@ascii[1]]"=="1" then^endiff
REM Works correctly with commands like "file -R .. dir1\*.* *fil*.* dir2" etc.
REM thanx to these messy lines below. Don't make any changes, please.
REM ..on the other hand, maybe ls.btm-like filename grouping would be needed?
:over
iff isdir %1 then^set do=%1\*.*^else^set do=%1^endiff
if "%@path[%@full[%do]]" != "%home" cd %@path[%@full[%do]]
set do=%@substr[%do,%@len[%@path[%do]]]
%[g]%[h] gosub work^cd ->&nul^shift^if "%1" != "" goto over^goto end
:work
REM Shield against empty dir error message; Cannot use "if not exist %do return"
REM to be able to check extensions *without* existing file eg. "file foo.bar".
if not exist %do .and. %@index[%do,?] != -1 .or. %@index[%do,*] != -1 return
if "%[%@ascii[R]]"=="1" .and. not exist %do .and. %@index[%do,?]==-1 .and. %@index[%do,*]==-1 return
REM Does the directory exist? If yes, then if files to be identified are not
REM in current directory, show their path. Have to show *absolute* path..
REM Structure if "0"=="1" iff "1"=="1" then^echo ERROR^endiff does not work,
REM but if "0"=="1" if "1"=="1" echo NO ERROR does work. 4DOS 4.01 revision D.
if isdir %@path[%@full[%do]] if "%_cwds" != "%home" echo [%@upper[%_cwds]]
REM Identify file type - optimized Stetson Method (linear search in unsorted data)
REM Could increase reliability by studying path/directory/file names and other
REM files in current dir and trying to guess kind of files we are dealing with
REM .spl compressed file archive created by SPLINT (splint.arc)
REM .spl customized printer driver (Sprint)
REM .spl print spooling file (MS Windows)
REM Files for which u want a description doesn't have to exist and *.* is OK.
for /a-d %a in (%do) (
iff "%[%@ext[%a]]" != "1" then
echos %@name[%a]
iff "%@ext[%a]"=="" then
screen %_row %PLAZA ----- No File Extensionn
else
echos .%@ext[%a]
if "%[%@ascii[*]]"=="1" gosub bells
%TOOL ".%@ext[%a] " %DATA | set d=%@line[con,0]
iff %@ascii[%d] != 46 then
screen %_row %PLAZA ----- Unknown File Typen
else
screen %_row %PLAZA %@substr[%d,%@len[.%@ext[%a]]]n
endiff
if "%[%@ascii[1]]"=="1" set %@ext[%a]=1
endiff
endiff
)
return^goto end
REM This is highly system dependent, you have to re-configure it before using.
REM You need WordCount with -l (line) switch, "wc-f" is my version of it
REM and gives output as I wish == in the first column.
:bells
if "%@search[wc-f]"=="" return
fgrep -sx ".%@ext[%a] " %DATA | wc-f -l | set d=%@line[con,0]
if "%d" gt "1" screen %_row %@eval[%PLAZA-1] *
return^goto end
:info
echo Usage: %@lower[%@name[%0]] [-options] file | directory ..
text
-* notify when several possible descriptions
-1 only unique file extensions
-a all files (also hidden and system)
-R process recursively all subdirectories
Identifies DOS files by making a very good guess based on their file
extension. Needs a database file and some kind of GREP clone (FIND).
endtext
:end
break off^quit
REM In theory we don't need that final "quit", but in practice we do:
REM 4DOS 4.01 revision B
REM gosub end
REM echo ERROR
REM :end
REM echo END