home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / DOS / 4DOS / UTILS / PKBTM / PK.BAT < prev    next >
DOS Batch File  |  1992-01-18  |  14KB  |  612 lines

  1. @REM Pk.btm v1.03 (C) 1992 FMMO Publications informatiques
  2. @REM [Unregistered Shareware Evaluation Copy]
  3. @REM Please make sure you distrubute this file as a single package with the
  4. @REM following files: desclist.fmm
  5. @REM                  fmmhost.bbs
  6. @REM                  menudisp.fmm
  7. @REM                  pkvar.lst
  8. @REM                  pkbtm.doc
  9. @REM                  magicn.fmo
  10.  
  11. @Echo off
  12.  
  13. if not "%cwd"=="" goto not4dos
  14. if %_4ver LT 4.0 goto notv40
  15.  
  16. Loadbtm on
  17. Setlocal
  18.  
  19. REM **************************************************************
  20. REM Make sure you set the correct path !
  21.  
  22. Set /r c:\batch\pkbtm\pkvar.lst
  23.  
  24. REM **************************************************************
  25.  
  26. %keystackpath >& nul
  27. setdos /M0
  28.  
  29. If "%1" ne "" goto fil_sel_by_cmdline
  30.  
  31. :pick
  32. cls
  33. screen 0 0 Working...
  34. set pkfile=!
  35. set isitadir=no
  36. >%processfile
  37. set currentpath=%_cwd
  38. select /oe set isitadir=(*.*)
  39. iff %isitadir==. then
  40. goto pick
  41. else
  42. iff %isitadir==no then
  43. gosub dispabort
  44. %afterquit
  45. quit
  46. else
  47. cd %isitadir >&> %processfile
  48. endiff
  49. iff %_? ne 0 then
  50. echo Working...
  51. type %processfile |eset pkfile >nul
  52. keystack @83 @83 @83 @83 @83 @83 @83 @83 @83 @83 @83 @83 @83 @83 @79 8 13
  53. eset pkfile >nul
  54. goto outpick
  55. endiff
  56. goto pick
  57.  
  58.  
  59. :fil_sel_by_cmdline
  60. Set pkfile=%1
  61. :outpick
  62. If not "%@ext[%pkfile]"=="zip" gosub zipthis
  63. Set pkfile=%@full[%@path[%pkfile]%@name[%pkfile].zip]
  64. If "%flagforlogo"=="no" goto nologo
  65. Text
  66.  
  67. Putting logo into file ...
  68.  
  69. Endtext
  70. set error=%@exec[%pkzippath %@full[%pkfile] -z < %logofile]
  71. If %error ne 0 goto decompressing_error
  72.  
  73. :nologo
  74. If "%@descript[%@full[%pkfile]]"=="" Describe %@full[%pkfile] "%nodesc"
  75.  
  76. :redisplay
  77.  
  78. Cls
  79. Gosub showtitle
  80.  
  81. Screen 6 0
  82. Text
  83.  Current path is             :
  84.  Current working file is     :
  85.  Current file description is :
  86. Endtext
  87.  
  88. Drawbox 4 0 10 77 1  blu on bla
  89. Scrput 6 31 bri whi on bla %_cwd
  90. Scrput 7 31 bri whi on bla %@full[%pkfile]
  91. Scrput 8 31 bri whi on bla %@descript[%@full[%pkfile]]
  92. Gosub menu
  93. Goto out
  94.  
  95. :menu
  96.  
  97. Screen 11 1 please select what you want to do |
  98.  
  99. Text
  100.  
  101.  
  102.  
  103.        Unarchive current file to
  104.        Clear                                                    
  105.        Update description
  106.        Select another file
  107.        Unarchive to a specified directory
  108.        View current file (for ZIP only)
  109.        Scan file for viruses
  110.        Unarchive a specified file in this archive
  111. Endtext
  112. scrput 22 7 bri cyan on bla Simple file operations (submenu)
  113. Scrput 14 33 bri yellow on bla %downloaddirtry
  114. Scrput 15 13 bri yellow on bla %downloaddirtry
  115.  
  116. Drawbox 13 5 23 79 1 blue on bla
  117.  
  118. Set answer=%@select[%menudisp,14,0,%@eval[%_rows-1],2]
  119.  
  120. Iff "%@substr[%answer,1,1]"=="0" then^goto explode^endiff
  121. Iff "%@substr[%answer,1,1]"=="1" then^goto deldown^endiff
  122. Iff "%@substr[%answer,1,1]"=="2" then^goto describe^endiff
  123. Iff "%@substr[%answer,1,1]"=="3" then^goto select^endiff
  124. Iff "%@substr[%answer,1,1]"=="4" then^goto unzip^endiff
  125. Iff "%@substr[%answer,1,1]"=="5" then^goto view^endiff
  126. Iff "%@substr[%answer,1,1]"=="6" then^goto scanfile^endiff
  127. Iff "%@substr[%answer,1,1]"=="7" then^goto unarcspecified^endiff
  128. Iff "%@substr[%answer,1,1]"=="8" then
  129. Goto operations
  130. Else
  131. Cls
  132. Gosub dispabort
  133. %afterquit
  134. Quit
  135. Endiff
  136.  
  137. :zipthis
  138.  
  139.  if  "%@ext[%pkfile]"=="lzh" goto lzhzip
  140.  if  "%@ext[%pkfile]"=="arc" goto arczip
  141.  if  "%@ext[%pkfile]"=="arj" goto arjzip
  142.  
  143. Gosub redisplay
  144. Return
  145.  
  146. :lzhzip
  147. Gosub maketempdir
  148. set processlzhfile=%@full[%pkfile]
  149. cdd %tempdir
  150. Gosub showtitle
  151. text
  152.  
  153. endtext
  154. if exist %lzhpath %lzhpath e %@full[%processlzhfile]
  155. If %? ne 0 goto decompressing_error
  156. Gosub filter
  157. Gosub scanit
  158.  
  159. Del %@full[%processlzhfile]
  160.  
  161. %pkzippath %downloaddir\%@name[%pkfile].zip %tempdir\*.* -m
  162. If %? ne 0 goto decompressing_error
  163. Cdd %downloaddir
  164. Rd %tempdir
  165. Return
  166.  
  167. :arjzip
  168. gosub showtitle
  169. Gosub maketempdir
  170. set processarjfile=%@full[%pkfile]
  171. Cdd %tempdir
  172. Gosub showtitle
  173. text
  174.  
  175. endtext
  176. if exist %arjpath %arjpath e %@full[%processarjfile]
  177. If %? ne 0 goto decompressing_error
  178. Gosub filter
  179. Gosub scanit
  180. Del %@full[%processarjfile]
  181. %pkzippath %downloaddir\%@name[%pkfile].zip %tempdir\*.* -m
  182. If %? ne 0 goto decompressing_error
  183. Cdd %downloaddir
  184. Rd %tempdir
  185. Return
  186.  
  187. :arczip
  188. Gosub maketempdir
  189. set processarcfile=%@full[%pkfile]
  190. Cdd %tempdir
  191. Gosub showtitle
  192. Text
  193.  
  194. Endtext
  195. if exist %arcpath %arcpath %@full[%processarcfile]
  196. If %? ne 0 goto decompressing_error
  197. Gosub filter
  198. Gosub scanit
  199. Del %@full[%processarcfile]
  200. %pkzippath %downloaddir\%@name[%pkfile].zip %tempdir\*.* -m
  201. If %? ne 0 goto decompressing_error
  202. Cdd %downloaddir
  203. Rd %tempdir
  204. Return
  205.  
  206. Return
  207.  
  208.  
  209. :unarcspecified
  210. cls
  211. Echo Working...
  212. if exist e:\arcfmmo.lst del e:\arcfmmo.lst >nul
  213. set error=%@exec[ %pkzippath -v %@full[%pkfile] >> %arcfmmo ]
  214. gosub showtitle
  215. set pickazip=%@select[%arcfmmo,3,0,%@eval[%_ROWS-1],79,Pick a line which has a zip file on it !]
  216. iff not "%pickazip"=="" then
  217. cls
  218. else
  219. goto redisplay
  220. endiff
  221.  
  222. set pksel=%@substr[%pickazip,60,12]
  223.  
  224. iff "%viewtolist"="on" then
  225. cls
  226. Text
  227. Gathering selected information ...
  228.  
  229. Endtext
  230. set error=%@exec[ %pkunzippath %@full[%pkfile] %pksel -c | %listpath /s]
  231. If %error ne 0 goto decompressing_error
  232. set viewtolist=off
  233. goto operations
  234. endiff
  235.  
  236. cls
  237. gosub showtitle
  238. Scrput 3 0 whi on bla The file wich you chosed to process is :
  239. Scrput 3 41 cyan on bla %pksel
  240. Screen 5 0
  241. Inkey /K"yn" Do you want to extract it from %pkfile (y/n) ? %%answer
  242. If not "%answer"=="y" goto redisplay
  243. Text
  244.  
  245. Hope you know what you're doing...
  246.  
  247. Endtext
  248. set error=%@exec[ %pkunzippath %@full[%pkfile] %pksel %downloaddirtry ]
  249. If %error ne 0 goto decompressing_error
  250. set error=%@exec[ %Scanpath  %downloaddirtry\*.* %scanopt ]
  251. If %error ne 0 goto dispinfected
  252. Cdd %downloaddirtry
  253. Echo This is the contents of %downloaddirtry
  254. Dir %diropt %downloaddirtry
  255. Pushd
  256. Goto out
  257. Endiff
  258.  
  259. :scanfile
  260. Cls
  261. Text
  262. This will scan an archive but will not see trough it ...
  263.  
  264. Endtext
  265. Echo Scanning %@full[%pkfile] for viruses ...
  266. Text
  267.  
  268. Endtext
  269. %Scanpath  %@full[%pkfile] %scanopt
  270. If %? ne 0 gosub dispinfected
  271. goto redisplay
  272.  
  273. :dispinfected
  274. Text
  275. This archive seems to be infected with a virus
  276. Watch Out! The original file is still in it's original form
  277. Quitting...
  278. Endtext
  279. del %tempdir\*.* /y /q
  280. cdd %downloaddir
  281. rd %tempdir
  282. goto out
  283.  
  284. :select
  285. Goto pick
  286.  
  287. :explode
  288. Cls
  289. set error=%@exec[ %Pkunzippath %@full[%pkfile] %downloaddirtry ]
  290. If %error NE 0 goto decompressing_error
  291. set error=%@exec[ %Scanpath %downloaddirtry\*.* %scanopt ]
  292. If %error ne 0 goto dispinfected
  293. Dir %diropt %downloaddirtry
  294. popd *
  295. cdd %downloaddirtry
  296. Pushd %downloaddirtry
  297. Goto out
  298.  
  299. :operations
  300. Cls
  301. Gosub showtitle
  302. Scrput 12 5 bri cyan on bla -Press Escape to Go Back to Main Menu-
  303. Screen 6 0
  304. Text
  305.  current path is             :
  306.  current working file is     :
  307.  current file description is :
  308. Endtext
  309.  
  310. Drawbox 4 0 10 77 1  blu on bla
  311. Scrput 6 31 bri whi on bla %_cwd
  312. Scrput 7 31 bri whi on bla %@full[%pkfile]
  313. Scrput 8 31 bri whi on bla %@descript[%@full[%pkfile]]
  314. Screen 11 1 please select what you want to do |
  315.  
  316. Text
  317.  
  318.  
  319.  
  320.        Delete file
  321.        View file using e.g. Chris Buerg's List.com
  322.        Shell to command interpreter
  323.        Explode a selected file to the file viewer
  324.        Empty slot
  325.        Empty slot
  326.        Empty slot
  327.        Empty slot
  328.        Empty slot
  329. Endtext
  330. Drawbox 13 5 23 79 1 blue on bla
  331. Set answer=%@select[%menudisp,14,0,%@eval[%_rows-1],2]
  332.  
  333. Iff "%@substr[%answer,1,1]"=="0" then ^ goto deletefile^endiff
  334. Iff "%@substr[%answer,1,1]"=="1" then ^ goto viewbuerg^endiff
  335. Iff "%@substr[%answer,1,1]"=="2" then ^ goto shellto4DOS^endiff
  336. Iff "%@substr[%answer,1,1]"=="3" then ^ set viewtolist=on^ goto unarcspecified^endiff
  337. Iff "%@substr[%answer,1,1]"=="4" then ^ goto emptyslot^endiff
  338. Iff "%@substr[%answer,1,1]"=="5" then ^ goto emptyslot^endiff
  339. Iff "%@substr[%answer,1,1]"=="6" then ^ goto emptyslot^endiff
  340. Iff "%@substr[%answer,1,1]"=="7" then ^ goto emptyslot^endiff
  341. Iff "%@substr[%answer,1,1]"=="8" then ^ goto emptyslot
  342. Else
  343. Cls
  344. Goto redisplay
  345. Endiff
  346.  
  347. :deletefile
  348. cls
  349. Echo Deleting %@full[%pkfile] ..
  350. Del %@full[%pkfile] >nul
  351. goto select
  352.  
  353. :movefile
  354. :copyfile
  355. :edit file
  356. :execute_file
  357.  
  358. :shellto4dos
  359. set result=%@exec[%comspec]
  360. goto operations
  361.  
  362. :viewbuerg
  363. iff exist %listpath then
  364. set result=%@exec[ %listpath %@full[%pkfile] ]
  365. endiff
  366. Goto operations
  367.  
  368. :emptyslot
  369. cls
  370. Text
  371.  
  372. This is an empty slot so you could put something of your own !
  373. If you register, we will be glad to send you some usable code
  374. to fill all those empty slots and more !
  375.  
  376. Just shell and go read pkbtm.doc
  377. Endtext
  378.                                                                                       REM Remember, the source is also available for a light supplement of 10$  :-))
  379. Pause
  380. Goto operations
  381.  
  382. :describe
  383. Keystack "%@descript[%@full[%pkfile]]"
  384. :reask
  385. Scrput 3 0 bri red on bla Enter the new description.  Press ESC and ENTER to be prompted for a choice !
  386. Screen 9 30 └────────────────────────────────────────┘
  387. Screen 8 31
  388. Input %%newdes
  389. Iff %@len[%newdes] gt 40 then
  390. Keystack "%newdes"
  391. Goto reask
  392. Endiff
  393.  
  394. :descentered
  395. Iff "%newdes" ne "" then
  396. Describe %@full[%pkfile] ""
  397. Echo %newdes | describe %@full[%pkfile] >nul
  398. goto redisplay
  399. Endiff
  400. cls
  401. set newdes=%@select[%descriptionlist,2,0,24,79,Please Select a Description Among These !]
  402. If not "%newdes" ne "" set newdes=%nodesc
  403. goto descentered
  404.  
  405. :deldown
  406. Cls
  407. Echo This is the content of %downloaddirtry
  408. Text
  409.  
  410. Endtext
  411. Dir %diropt %downloaddirtry
  412. Text
  413.  
  414. Endtext
  415. Inkey /K"yn" Do you want to delete the content of %downloaddirtry (y/n) : %%answer
  416. Iff "%answer"=="y" then
  417. Text
  418.  
  419. Deleting...
  420. endtext
  421. set result=%@exec[%deleteprotect_off >& nul ]
  422. If exist %downloaddirtry\*.* del %downloaddirtry\*.* /y /q >& nul
  423. set result=%@exec[%deleteprotect_on >& nul ]
  424. Goto redisplay
  425. Endiff
  426. text
  427.  
  428. endtext
  429. Inkey /K"yn" Do you want to move that somewhere ? (y/n) : %%answer
  430. If "%answer"=="n" goto redisplay
  431. Text
  432.  
  433. Endtext
  434. Input Where do you want to move that (ENTER to quit): %%where
  435. If "%where"=="" goto redisplay
  436. Iff not isdir %where then
  437. Text
  438.  
  439. You need to specify an existing directory !
  440. I'll try to create it ...
  441.  
  442. Endtext
  443. Goto makedir
  444. Endiff
  445. Echo Moving files to %where ...
  446. Move %downloaddirtry\*.* %where
  447. Iff %_? NE 0 then
  448. Text
  449. An error as occured when moving files ..
  450. Quitting...
  451. Endtext
  452. %afterquit
  453. Cancel
  454. Else
  455. Goto redisplay
  456. Endiff
  457.  
  458. :makedir
  459. Md  %where >& nul
  460. Set error=%_?
  461. Text
  462.  
  463. Endtext
  464. If "%error" != "0" goto imposs_dir
  465.  
  466. Echo The directory %where was succesfully created !
  467. Echo Moving files to %where ...
  468. Text
  469.  
  470. Endtext
  471. Move %downloaddirtry\*.* %where
  472. Goto redisplay
  473.  
  474. :imposs_dir
  475. Text
  476.  
  477. 4DOS is not able to create this directory :-)
  478. Please revise 4DOS.DOC !
  479.  
  480. Endtext
  481. Pause
  482. Goto redisplay
  483.  
  484. :view
  485. Cls
  486. Echo Gathering information on zip file...
  487. Iff "%@ext[%@full[%pkfile]]"=="zip" then
  488. set error=%@exec[ %pkzippath -v %@full[%pkfile] | %listpath /s ]
  489. else
  490. Text
  491.  
  492. Not a zip archive ...
  493. Endtext
  494. pause
  495. endiff
  496. @goto redisplay
  497.  
  498. :unzip
  499. Cls
  500. Input Where do you want to unzip %pkfile : %%where
  501. If "%where"=="" goto redisplay
  502. If isdir %where goto dirok
  503. md %where >& nul
  504. Set error=%_?
  505. Text
  506.  
  507. Endtext
  508. If %error != 0 goto imposs_dir
  509. Text
  510.  
  511. Endtext
  512. Echo The directory %where was succesfully created !
  513.  
  514. :dirok
  515. Text
  516.  
  517. Endtext
  518. Echo Unzippping files to %where ...
  519. set error=%@exec[%Pkunzippath %@full[%pkfile] %where]
  520. If %error NE 0 goto decompressing_error
  521. %Scanpath  %where /d %scanopt
  522. If  %? ne 0 goto dispinfected
  523. Cdd %where
  524. Cls
  525. Echo This is the content of %where
  526. Dir %diropt %where >&>nul
  527. Pushd
  528. Goto out
  529.  
  530. :upload
  531. Copy %@full[%pkfile] %uploaddir
  532. Goto out
  533.  
  534. :acm
  535. Cls
  536. Text
  537. Loading arcmaster....
  538. Endtext
  539. %arcmaster
  540. Goto redisplay
  541.  
  542. :decompressing_error
  543. Text
  544. 
  545. An error occured when processing this file.
  546. Please fix the problem.
  547. Endtext
  548. %afterquit
  549. Cancel
  550.  
  551.  
  552. :dispabort
  553. Text
  554. [UNREGISTERED EVALUATION COPY]
  555. Thanks for evaluating FMMO's software.
  556. Have a nice 4DOS !
  557. Endtext
  558. Return
  559.  
  560. :scanit
  561. %Scanpath %tempdir %scanopt
  562. If  %? ne 0 goto dispinfected
  563. Return
  564.  
  565. :filter
  566. If exist readmy.bbs del readmy.bbs
  567. If exist readme.ros del readme.ros
  568. If exist fmmobbs.doc del fmmobbs.doc
  569. Return
  570.  
  571. :maketempdir
  572.  
  573. If not isdir %tempdir md %tempdir
  574.     iff %_? ne 0 then
  575.         text
  576.         Fatal error
  577.         Could not create directory
  578.         endtext
  579.         goto out
  580.     endiff
  581. Return
  582.  
  583.  
  584. :showtitle
  585. cls
  586. Scrput 0 0 bri yellow on blu ≡         Pk.Btm v1.02 (C) 1991 FMMO Publications Informatiques Enr.           ≡
  587. Drawhline 1 0 80 1 blu on bla
  588. Return
  589.  
  590. :out
  591. If exist %menudisp del %menudisp >nul
  592. %afterquit
  593. Popd >& nul
  594. quit
  595.  
  596.  
  597. :notv40
  598. Echo Pk.btm is constantly updated to use the latest 4DOS functions.
  599. Echo As of now, the most recent version of 4DOS is the 11-01-91 v4.0 release.
  600. Echo Please read the file dl4dos.fmo for further information on
  601. Echo how to obtain the most recent version of 4DOS.
  602. quit
  603.  
  604. :not4dos
  605. @echo 
  606. @echo 4DOS (tm) is not loaded on your system. This batch file only works with it.
  607. @echo Feel free to download the latest version of 4DOS (tm) of JP Software from
  608. @echo FMMHOST BBS in Sherbrooke, Qc. (819) 820-0590 ANSI,n,8,1 HST 14.4/v.32bis
  609. @echo We are an official 4DOS Distribution Site !
  610. @Echo 1:167/440@fidonet, 81-91-10@nanet, FMMO@DMI.USherb.ca@Internet
  611.  
  612.