home *** CD-ROM | disk | FTP | other *** search
- :: COMF.BTM (=executes a command on a take file)
- :: Reads a specified file which contains a list of filenames
- :: and executes desired operation on each of the filenames one by one.
- :: Example: if you have a list of files which you wish to copy
- :: to a target, instead of putting "copy" at the beginning
- :: and the target name at the end of each line, you run this batch.
- :--------------------------------------------------------------------
- : Note: This file is a different version for COMFILE.BTM. It uses the
- : FOR procedure rather than reads the take file line by line. The same
- : procedure is also used for counting the number of files handled.
- : Itamar Even-Zohar, Tel Aviv University (itiez@ccsg.tau.ac.il)
- : Last edited March 7, 1993
- :--------------------------------------------------------------------
- :syntax
- iff .%1==. .or. .%2==. then
- echo.
- text
- SYNTAX:
- COMF <filename> <command> [target]
- (for example: COMF filelist copy a:)
- ('comfile filelist copy a:' will copy all files specified
- in FILELIST to drive a:
- (switches allowed if separated by only one space: 'copy /p', 'dir /klm')
- endtext
- quit
- endiff
-
- setlocal
- set rsp=%1
- set cmd=%2
- set trg=%3
- iff not .%4==. then set cmd=%2 %3^set trg=%4^endiff
- iff not exist %rsp then^echo File %@upper[%rsp] not found^quit^endiff
-
- :do_command
- : Checks if the files exist and only then preforms the command,
- : adding to the counter.
- : I would have preferred an internal errorlevel code, but none seems
- : to work, so I've settled for 'if exist'.
- set num=0
- *for %f in (@%rsp) do (
- if exist %f (
- %cmd %f %trg
- set num=%@eval[%num+1]
- )
- )
-
- :end
- if %_row ge 21 pause
- cls
- if %num==0 set num=No
- scrput %@eval[%_row+2] 0 bri whi on bla ==`>` %0 terminated (%num files handled)
- endlocal
- quit