I am pretty new to batch programming. I have found the program mentioned here here in the part of the accepted answer of "Makecab". I am inserting it here:
;@echo off
;;;;; rem start of the batch part ;;;;;
; if "%~2" EQU "" (
; echo invalid arguments.For help use:
; echo %~nx0 /h
;)
;for %%a in (/h /help -h -help) do (
; if "%~1" equ "%%~a" (
; echo compressing directory to cab file
; echo %~nx0 directory cabfile
; echo to uncompress use:
; echo EXPAND cabfile -F:* .
; )
; )
;
; set "dir_to_cab=%~f1"
;
; set "path_to_dir=%~pn1"
; set "dir_name=%~n1"
; set "drive_of_dir=%~d1"
; set "cab_file=%~2"
;
; if not exist %dir_to_cab%\ (
; echo no valid directory passed
; exit /b 1
;)
;
;break>"%tmp%\makecab.dir.ddf"
;
;setlocal enableDelayedExpansion
;for /d /r "%dir_to_cab%" %%a in (*) do (
;
; set "_dir=%%~pna"
; set "destdir=%dir_name%!_dir:%path_to_dir%=!"
; (echo(.Set DestinationDir=!destdir!>>"%tmp%\makecab.dir.ddf")
; for %%# in ("%%a\*") do (
; (echo("%%~s#" /inf=no>>"%tmp%\makecab.dir.ddf")
; )
;)
;(echo(.Set DestinationDir=!dir_name!>>"%tmp%\makecab.dir.ddf")
; for %%# in ("%~f1\*") do (
;
; (echo("%%~s#" /inf=no>>"%tmp%\makecab.dir.ddf")
; )
;makecab /F "%~f0" /f "%tmp%\makecab.dir.ddf" /d DiskDirectory1=%cd% /d CabinetNameTemplate=%cab_file%.cab
;del /q /f "%tmp%\makecab.dir.ddf"
;exit /b %errorlevel%
;;
;;;; rem end of the batch part ;;;;;
;;;; directives part ;;;;;
;;
.New Cabinet
.set GenerateInf=OFF
.Set Cabinet=ON
.Set Compress=ON
.Set UniqueFiles=ON
.Set MaxDiskSize=1215751680;
.set RptFileName=nul
.set InfFileName=nul
.set MaxErrors=1
;;
;;;; end of directives part ;;;;;
What difference does it make to use the semicolons in the beginning of each line? Also some lines have more than one semicolon, why is that?
What difference does it make to use the semicolons in the beginning of each line? Also some lines have more than one semicolon, why is that? Show activity on this post. The semicolon is a standard delimiter in batch files - along with <space>, <tab>, =,,. So for the batch file it means blank space.
The semicolon is a standard delimiter in batch files - along with <space>, <tab>, =,,. So for the batch file it means blank space. But this is a kind of polyglot script - it also a valid makecab directive where the ; means a comment.
That means when you use a semicolon, you use it instead of the ands, buts, and ors; you don’t need both. Here’s a hint: if you used a comma and an “and” to link two related ideas, think of the period (you know, the top part of the semicolon) as a replacement “and.”
But you shouldn’t use a semicolon and a conjunction. That means when you use a semicolon, you use it instead of the ands, buts, and ors; you don’t need both. Here’s a hint: if you used a comma and an “and” to link two related ideas, think of the period (you know, the top part of the semicolon) as a replacement “and.”
The semicolon is a standard delimiter in batch files - along with <space>
,<tab>
,=
,,
. So for the batch file it means blank space.
But this is a kind of polyglot script - it also a valid makecab directive where the ;
means a comment. It is like that in order to reduce IO operations and make the script a little bit faster and to avoid not so easy to read echo something>temp.file
lines as much as possible. Some lines are with more semicolons in order to emphasize the real comment lines.
Same trick can be used also with reg files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With