Skip to content

Commit

Permalink
Initial commit: scripts/recipes and snippets from the Batchography bo…
Browse files Browse the repository at this point in the history
  • Loading branch information
lallousx86 committed May 11, 2016
0 parents commit 1ab6f5a
Show file tree
Hide file tree
Showing 169 changed files with 5,041 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CmdInit.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
prompt $+%PROMPT%
doskey /macrofile=%~dp0cmdinit.macro
24 changes: 24 additions & 0 deletions annotated-code-sample.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
::
:: The Batchography book by Elias Bachaalany
::

:main
if exist log.txt del log.txt

pushd compiler
if not exist cl.exe (
echo The compiler was not found!
goto :end
)

cl.exe hello.c

if %ERRORLEVEL% EQU 0 (
echo Compilation successful!
) ELSE (
echo Compilation failed!
)

:end
POPD
1 change: 1 addition & 0 deletions args-1.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@echo arg0=%0, arg1=%1, arg2=%2
1 change: 1 addition & 0 deletions args-all.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@echo All arguments: %*
41 changes: 41 additions & 0 deletions args-check1.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@echo off

:main
if "%1"=="" goto Usage
if "%1"=="compress" goto compress
if "%1"=="uncompress" goto uncompress

rem Unknown command passed, display the usage!
echo Unknown command '%1'!!
goto usage

:Usage
ECHO %0 compress^|uncompress archive.zip
goto end

:compress
if "%2"=="" (
echo No archive name was passed!
goto Usage
)

echo Compressing current folder into archive '%2'
REM invoke the compression utility
goto end

:uncompress
if "%2"=="" goto Usage
if "%2"=="" (
echo No archive name was passed!
goto Usage
)

if not exist %2 (
ECHO The archive '%2' is not found!
goto end
)
echo Uncompressing the archive '%2' into the current folder
REM invoke the decompression utility
goto end

:end
16 changes: 16 additions & 0 deletions args-enum1.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off

::
:: The Batchography book by Elias Bachaalany
::


:repeat
if "%1"=="" goto end
echo Arg: %1

SHIFT

goto repeat

:end
7 changes: 7 additions & 0 deletions args-enum2.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off

echo Args 1 to 6 are: %1 %2 %3 %4 %5 %6

shift /3

echo New args 1 to 6 are: %1 %2 %3 %4 %5 %6
23 changes: 23 additions & 0 deletions args-modifiers-0.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off

::
:: The Batchography book by Elias Bachaalany
::

echo Self is: %0

:: Start modifiers example
echo 1. without quotes: %~0
echo 2. fully qualified path name: %~f0
echo 3. drive letter: %~d0
echo 4. path part: %~p0
echo 5. just the file name part: %~n0
echo 6. just the extension part: %~x0
echo 7. file's attributes: %~a0
echo 8. file's date and time: %~t0
echo 9. file's size: %~z0
echo 10. file path in the PATH environment variable search: %~$PATH:0
echo 11. file's full path: %~dp0
echo 12. file's name and extension part: %~nx0
echo 13. 'dir' like modifier: %~ftza0
echo 14. fully qualified script path: %~dpnx0
19 changes: 19 additions & 0 deletions args-modifiers.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off

echo The first argument as is: %1

:: Start modifiers example
echo 1. without quotes: %~1
echo 2. fully qualified path name: %~f1
echo 3. drive letter: %~d1
echo 4. path part: %~p1
echo 5. just the file name part: %~n1
echo 6. just the extension part: %~x1
echo 7. file's attributes: %~a1
echo 8. file's date and time: %~t1
echo 9. file's size: %~z1
echo 10. file path in the PATH environment variable search: %~$PATH:1
echo 11. file's full path: %~dp1
echo 12. file's name and extension part: %~nx1
echo 13. 'dir' like modifier: %~ftza1
echo 14. fully qualified script path: %~dpnx0
Loading

0 comments on commit 1ab6f5a

Please sign in to comment.