mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-30 12:15:56 +00:00
new skill batch-files (#1435)
* new skill batch-files * batch-files: codespell, re-run start, suggestions, txt assets codespellrc: add FO for tasklist option validate-readme: re-run npm start apply suggestions from code review batch-files: change asset templates to text files * codespellrc: resolve spelling in comment
This commit is contained in:
171
skills/batch-files/assets/executable.txt
Normal file
171
skills/batch-files/assets/executable.txt
Normal file
@@ -0,0 +1,171 @@
|
||||
@echo off
|
||||
REM myTool
|
||||
:: A standalone command-line tool template with argument parsing.
|
||||
::
|
||||
:: usage: myTool [options] [1] [2]
|
||||
:: [1] = input file path or value
|
||||
:: [2] = output file path (optional)
|
||||
::
|
||||
:: options:
|
||||
:: /? Show this help message
|
||||
:: -h Show this help message
|
||||
:: --help Show this help message
|
||||
:: -v Show version information
|
||||
:: --verbose Enable verbose output
|
||||
::
|
||||
:: examples:
|
||||
:: > myTool "C:\data\input.txt"
|
||||
:: > myTool "C:\data\input.txt" "C:\data\output.txt"
|
||||
:: > myTool --verbose "C:\data\input.txt"
|
||||
::
|
||||
set "_helpLinesMyTool=19"
|
||||
|
||||
:: ========================================================================
|
||||
:: TEMPLATE INSTRUCTIONS
|
||||
:: 1. Find/Replace "myTool" with your executable name (camelCase).
|
||||
:: 2. Find/Replace "MyTool" with your executable name (PascalCase).
|
||||
:: 3. Update the help block above (lines 2-19) for your tool.
|
||||
:: 4. Implement your logic in :_runMyTool.
|
||||
:: 5. Add any new variables to :_removeBatchVariablesMyTool.
|
||||
:: ========================================================================
|
||||
|
||||
:: Config variables.
|
||||
set "_versionMyTool=1.0.0"
|
||||
set "_verboseMyTool=0"
|
||||
|
||||
:: Define paths.
|
||||
set "_scriptDirMyTool=%~dp0"
|
||||
set "_scriptNameMyTool=%~n0"
|
||||
|
||||
:: Parse arguments into variables.
|
||||
set "_parOneMyTool=%~1"
|
||||
set "_checkParOneMyTool=-%_parOneMyTool%-"
|
||||
set "_parTwoMyTool=%~2"
|
||||
set "_checkParTwoMyTool=-%_parTwoMyTool%-"
|
||||
set "_parThreeMyTool=%~3"
|
||||
set "_checkParThreeMyTool=-%_parThreeMyTool%-"
|
||||
|
||||
:: -----------------------------------------------------------------------
|
||||
:: Handle help and version flags.
|
||||
:: -----------------------------------------------------------------------
|
||||
if "%_parOneMyTool%"=="/?" call :_showHelpMyTool & goto _removeBatchVariablesMyTool
|
||||
if /i "%_parOneMyTool%"=="-h" call :_showHelpMyTool & goto _removeBatchVariablesMyTool
|
||||
if /i "%_parOneMyTool%"=="--help" call :_showHelpMyTool & goto _removeBatchVariablesMyTool
|
||||
if /i "%_parOneMyTool%"=="-v" (
|
||||
echo %_scriptNameMyTool% version %_versionMyTool%
|
||||
goto _removeBatchVariablesMyTool
|
||||
)
|
||||
|
||||
:: -----------------------------------------------------------------------
|
||||
:: Handle --verbose flag (shift arguments if present).
|
||||
:: -----------------------------------------------------------------------
|
||||
if /i "%_parOneMyTool%"=="--verbose" (
|
||||
set "_verboseMyTool=1"
|
||||
set "_parOneMyTool=%~2"
|
||||
set "_checkParOneMyTool=-%~2-"
|
||||
set "_parTwoMyTool=%~3"
|
||||
set "_checkParTwoMyTool=-%~3-"
|
||||
)
|
||||
|
||||
:: Create temp directory for intermediate files.
|
||||
call :_makeTempDirMyTool
|
||||
|
||||
:: -----------------------------------------------------------------------
|
||||
:: Validate required input and start execution.
|
||||
:: -----------------------------------------------------------------------
|
||||
if "%_checkParOneMyTool%"=="--" (
|
||||
echo ERROR: No input specified. Run "%_scriptNameMyTool% /?" for usage. 1>&2
|
||||
goto _removeBatchVariablesMyTool
|
||||
)
|
||||
|
||||
call :_startMyTool
|
||||
goto _removeBatchVariablesMyTool
|
||||
|
||||
:: ========================================================================
|
||||
:: MAIN LOGIC
|
||||
:: ========================================================================
|
||||
|
||||
:_startMyTool
|
||||
if "%_verboseMyTool%"=="1" (
|
||||
echo [VERBOSE] Input: %_parOneMyTool%
|
||||
echo [VERBOSE] Output: %_parTwoMyTool%
|
||||
)
|
||||
|
||||
REM Validate input file exists.
|
||||
if NOT EXIST "%_parOneMyTool%" (
|
||||
echo ERROR: Input file not found: %_parOneMyTool% 1>&2
|
||||
goto :eof
|
||||
)
|
||||
|
||||
call :_runMyTool
|
||||
goto :eof
|
||||
|
||||
:_runMyTool
|
||||
REM ===================================================================
|
||||
REM TODO: Replace this section with your tool's logic.
|
||||
REM ===================================================================
|
||||
echo Processing: %_parOneMyTool%
|
||||
|
||||
if NOT "%_checkParTwoMyTool%"=="--" (
|
||||
echo Output to: %_parTwoMyTool%
|
||||
REM Example: copy input to output.
|
||||
REM copy /Y "%_parOneMyTool%" "%_parTwoMyTool%" >nul
|
||||
)
|
||||
|
||||
echo Done.
|
||||
goto :eof
|
||||
|
||||
:: ========================================================================
|
||||
:: SUPPORT FUNCTIONS
|
||||
:: ========================================================================
|
||||
|
||||
:_showHelpMyTool
|
||||
echo:
|
||||
for /f "skip=1 delims=" %%a in ('findstr /n "^" "%~f0"') do (
|
||||
set "_line=%%a"
|
||||
setlocal EnableDelayedExpansion
|
||||
for /f "delims=:" %%n in ("!_line!") do set "_lineNum=%%n"
|
||||
if !_lineNum! GTR %_helpLinesMyTool% (
|
||||
endlocal
|
||||
goto :eof
|
||||
)
|
||||
set "_text=!_line:*:=!"
|
||||
if defined _text (
|
||||
echo !_text:~4!
|
||||
) else (
|
||||
echo:
|
||||
)
|
||||
endlocal
|
||||
)
|
||||
goto :eof
|
||||
|
||||
:_makeTempDirMyTool
|
||||
set "_tmpDirMyTool=%TEMP%\%~n0_%RANDOM%%RANDOM%"
|
||||
set "_tmpDirCreatedMyTool=0"
|
||||
if NOT EXIST "%_tmpDirMyTool%" (
|
||||
mkdir "%_tmpDirMyTool%" >nul 2>nul
|
||||
set "_tmpDirCreatedMyTool=1"
|
||||
)
|
||||
goto :eof
|
||||
|
||||
:: ========================================================================
|
||||
:: CLEANUP — Remove all batch variables.
|
||||
:: ========================================================================
|
||||
:_removeBatchVariablesMyTool
|
||||
set _helpLinesMyTool=
|
||||
set _versionMyTool=
|
||||
set _verboseMyTool=
|
||||
set _scriptDirMyTool=
|
||||
set _scriptNameMyTool=
|
||||
set _parOneMyTool=
|
||||
set _checkParOneMyTool=
|
||||
set _parTwoMyTool=
|
||||
set _checkParTwoMyTool=
|
||||
set _parThreeMyTool=
|
||||
set _checkParThreeMyTool=
|
||||
REM Append new variables above this line.
|
||||
|
||||
if "%_tmpDirCreatedMyTool%"=="1" if EXIST "%_tmpDirMyTool%" rmdir /S /Q "%_tmpDirMyTool%" >nul 2>nul
|
||||
set _tmpDirMyTool=
|
||||
set _tmpDirCreatedMyTool=
|
||||
exit /b
|
||||
188
skills/batch-files/assets/library.txt
Normal file
188
skills/batch-files/assets/library.txt
Normal file
@@ -0,0 +1,188 @@
|
||||
@echo off
|
||||
REM myLib
|
||||
:: A reusable function library with CALL-able labels.
|
||||
::
|
||||
:: usage: call myLib [function] [args...]
|
||||
:: Functions:
|
||||
:: trimWhitespace [inputVar] Trim leading/trailing spaces
|
||||
:: toLower [inputVar] Convert value to lowercase
|
||||
:: getTimestamp [outputVar] Get current date-time stamp
|
||||
:: logMessage [level] [message] Write a log entry
|
||||
:: padRight [string] [width] Right-pad a string with spaces
|
||||
::
|
||||
:: examples:
|
||||
:: > set "myVar= Hello World "
|
||||
:: > call myLib trimWhitespace myVar
|
||||
:: > call myLib getTimestamp _now
|
||||
:: > call myLib logMessage INFO "Acme Corp backup started"
|
||||
::
|
||||
set "_helpLinesMyLib=17"
|
||||
|
||||
:: ========================================================================
|
||||
:: TEMPLATE INSTRUCTIONS
|
||||
:: 1. Find/Replace "myLib" with your library name (camelCase).
|
||||
:: 2. Find/Replace "MyLib" with your library name (PascalCase).
|
||||
:: 3. Add your own :_funcNameMyLib labels below.
|
||||
:: 4. Update the help block above (lines 2-17) for your library.
|
||||
:: 5. Add any new variables to :_removeBatchVariablesMyLib.
|
||||
:: ========================================================================
|
||||
|
||||
:: Route to the requested function.
|
||||
set "_funcMyLib=%~1"
|
||||
set "_argOneMyLib=%~2"
|
||||
set "_argTwoMyLib=%~3"
|
||||
set "_argThreeMyLib=%~4"
|
||||
|
||||
if "%_funcMyLib%"=="/?" call :_showHelpMyLib & goto _removeBatchVariablesMyLib
|
||||
if /i "%_funcMyLib%"=="-h" call :_showHelpMyLib & goto _removeBatchVariablesMyLib
|
||||
if /i "%_funcMyLib%"=="--help" call :_showHelpMyLib & goto _removeBatchVariablesMyLib
|
||||
|
||||
if /i "%_funcMyLib%"=="trimWhitespace" call :_trimWhitespaceMyLib & goto _removeBatchVariablesMyLib
|
||||
if /i "%_funcMyLib%"=="toLower" call :_toLowerMyLib & goto _removeBatchVariablesMyLib
|
||||
if /i "%_funcMyLib%"=="getTimestamp" call :_getTimestampMyLib & goto _removeBatchVariablesMyLib
|
||||
if /i "%_funcMyLib%"=="logMessage" call :_logMessageMyLib & goto _removeBatchVariablesMyLib
|
||||
if /i "%_funcMyLib%"=="padRight" call :_padRightMyLib & goto _removeBatchVariablesMyLib
|
||||
|
||||
echo ERROR: Unknown function "%_funcMyLib%". Run "%~n0 /?" for usage.
|
||||
goto _removeBatchVariablesMyLib
|
||||
|
||||
:: ========================================================================
|
||||
:: LIBRARY FUNCTIONS
|
||||
:: ========================================================================
|
||||
|
||||
:_trimWhitespaceMyLib
|
||||
REM Trim leading and trailing spaces from a variable.
|
||||
REM %_argOneMyLib% = name of the variable to trim (passed by name).
|
||||
if not defined _argOneMyLib goto :eof
|
||||
setlocal EnableDelayedExpansion
|
||||
set "_valMyLib=!%_argOneMyLib%!"
|
||||
REM Trim leading spaces.
|
||||
for /f "tokens=* delims= " %%a in ("!_valMyLib!") do set "_valMyLib=%%a"
|
||||
REM Trim trailing spaces.
|
||||
:_trimTrailingMyLib
|
||||
if "!_valMyLib:~-1!"==" " (
|
||||
set "_valMyLib=!_valMyLib:~0,-1!"
|
||||
goto _trimTrailingMyLib
|
||||
)
|
||||
endlocal & set "%_argOneMyLib%=%_valMyLib%"
|
||||
goto :eof
|
||||
|
||||
:_toLowerMyLib
|
||||
REM Convert a variable's value to lowercase.
|
||||
REM %_argOneMyLib% = name of the variable to convert (passed by name).
|
||||
if not defined _argOneMyLib goto :eof
|
||||
setlocal EnableDelayedExpansion
|
||||
set "_valMyLib=!%_argOneMyLib%!"
|
||||
set "_valMyLib=!_valMyLib:A=a!"
|
||||
set "_valMyLib=!_valMyLib:B=b!"
|
||||
set "_valMyLib=!_valMyLib:C=c!"
|
||||
set "_valMyLib=!_valMyLib:D=d!"
|
||||
set "_valMyLib=!_valMyLib:E=e!"
|
||||
set "_valMyLib=!_valMyLib:F=f!"
|
||||
set "_valMyLib=!_valMyLib:G=g!"
|
||||
set "_valMyLib=!_valMyLib:H=h!"
|
||||
set "_valMyLib=!_valMyLib:I=i!"
|
||||
set "_valMyLib=!_valMyLib:J=j!"
|
||||
set "_valMyLib=!_valMyLib:K=k!"
|
||||
set "_valMyLib=!_valMyLib:L=l!"
|
||||
set "_valMyLib=!_valMyLib:M=m!"
|
||||
set "_valMyLib=!_valMyLib:N=n!"
|
||||
set "_valMyLib=!_valMyLib:O=o!"
|
||||
set "_valMyLib=!_valMyLib:P=p!"
|
||||
set "_valMyLib=!_valMyLib:Q=q!"
|
||||
set "_valMyLib=!_valMyLib:R=r!"
|
||||
set "_valMyLib=!_valMyLib:S=s!"
|
||||
set "_valMyLib=!_valMyLib:T=t!"
|
||||
set "_valMyLib=!_valMyLib:U=u!"
|
||||
set "_valMyLib=!_valMyLib:V=v!"
|
||||
set "_valMyLib=!_valMyLib:W=w!"
|
||||
set "_valMyLib=!_valMyLib:X=x!"
|
||||
set "_valMyLib=!_valMyLib:Y=y!"
|
||||
set "_valMyLib=!_valMyLib:Z=z!"
|
||||
endlocal & set "%_argOneMyLib%=%_valMyLib%"
|
||||
goto :eof
|
||||
|
||||
:_getTimestampMyLib
|
||||
REM Write a YYYY-MM-DD_HH-MM-SS timestamp into the named variable.
|
||||
REM %_argOneMyLib% = name of the output variable.
|
||||
REM NOTE: Uses %DATE% and %TIME% which are locale-dependent. The parsing
|
||||
REM below assumes US-style format (e.g., "Fri 04/18/2026" or "04/18/2026").
|
||||
REM Adjust the substring offsets for your locale, or use PowerShell for
|
||||
REM a locale-independent alternative:
|
||||
REM for /f %%a in ('powershell -nop -c "Get-Date -F yyyy-MM-dd_HH-mm-ss"') do set "var=%%a"
|
||||
if not defined _argOneMyLib goto :eof
|
||||
setlocal EnableDelayedExpansion
|
||||
REM Parse date — strip leading day name if present (e.g., "Fri ").
|
||||
set "_dtMyLib=%DATE%"
|
||||
if "!_dtMyLib:~3,1!"==" " set "_dtMyLib=!_dtMyLib:~4!"
|
||||
set "_stampMyLib=!_dtMyLib:~6,4!-!_dtMyLib:~0,2!-!_dtMyLib:~3,2!"
|
||||
REM Parse time — replace leading space with 0 for single-digit hours.
|
||||
set "_tmMyLib=%TIME: =0%"
|
||||
set "_stampMyLib=!_stampMyLib!_!_tmMyLib:~0,2!-!_tmMyLib:~3,2!-!_tmMyLib:~6,2!"
|
||||
endlocal & set "%_argOneMyLib%=%_stampMyLib%"
|
||||
goto :eof
|
||||
|
||||
:_logMessageMyLib
|
||||
REM Write a timestamped log line to stdout.
|
||||
REM %_argOneMyLib% = level (INFO, WARN, ERROR)
|
||||
REM %_argTwoMyLib% = message text
|
||||
REM NOTE: Uses %DATE% and %TIME% (locale-dependent). See :_getTimestampMyLib.
|
||||
setlocal EnableDelayedExpansion
|
||||
set "_dtMyLib=%DATE%"
|
||||
if "!_dtMyLib:~3,1!"==" " set "_dtMyLib=!_dtMyLib:~4!"
|
||||
set "_tmMyLib=%TIME: =0%"
|
||||
set "_tsMyLib=!_dtMyLib:~6,4!-!_dtMyLib:~0,2!-!_dtMyLib:~3,2! !_tmMyLib:~0,2!:!_tmMyLib:~3,2!:!_tmMyLib:~6,2!"
|
||||
echo [!_tsMyLib!] [%_argOneMyLib%] %_argTwoMyLib%
|
||||
endlocal
|
||||
goto :eof
|
||||
|
||||
:_padRightMyLib
|
||||
REM Pad a string to a given width with trailing spaces.
|
||||
REM %_argOneMyLib% = the string to pad
|
||||
REM %_argTwoMyLib% = desired total width
|
||||
if not defined _argOneMyLib goto :eof
|
||||
if not defined _argTwoMyLib goto :eof
|
||||
setlocal EnableDelayedExpansion
|
||||
set "_valMyLib=%_argOneMyLib%"
|
||||
set "_padMyLib=%_valMyLib% "
|
||||
set "_padMyLib=!_padMyLib:~0,%_argTwoMyLib%!"
|
||||
echo !_padMyLib!
|
||||
endlocal
|
||||
goto :eof
|
||||
|
||||
:: ========================================================================
|
||||
:: HELP
|
||||
:: ========================================================================
|
||||
|
||||
:_showHelpMyLib
|
||||
echo:
|
||||
for /f "skip=1 delims=" %%a in ('findstr /n "^" "%~f0"') do (
|
||||
set "_line=%%a"
|
||||
setlocal EnableDelayedExpansion
|
||||
for /f "delims=:" %%n in ("!_line!") do set "_lineNum=%%n"
|
||||
if !_lineNum! GTR %_helpLinesMyLib% (
|
||||
endlocal
|
||||
goto :eof
|
||||
)
|
||||
set "_text=!_line:*:=!"
|
||||
if defined _text (
|
||||
echo !_text:~4!
|
||||
) else (
|
||||
echo:
|
||||
)
|
||||
endlocal
|
||||
)
|
||||
goto :eof
|
||||
|
||||
:: ========================================================================
|
||||
:: CLEANUP — Remove all batch variables.
|
||||
:: ========================================================================
|
||||
:_removeBatchVariablesMyLib
|
||||
set _helpLinesMyLib=
|
||||
set _funcMyLib=
|
||||
set _argOneMyLib=
|
||||
set _argTwoMyLib=
|
||||
set _argThreeMyLib=
|
||||
set _valMyLib=
|
||||
REM Append new variables above this line.
|
||||
exit /b
|
||||
177
skills/batch-files/assets/task.txt
Normal file
177
skills/batch-files/assets/task.txt
Normal file
@@ -0,0 +1,177 @@
|
||||
@echo off
|
||||
REM myTask
|
||||
:: An automation script for scheduled or manual task execution.
|
||||
::
|
||||
:: usage: myTask [options]
|
||||
:: [1] = task target or configuration value (optional)
|
||||
::
|
||||
:: options:
|
||||
:: /? Show this help message
|
||||
:: -h Show this help message
|
||||
:: --help Show this help message
|
||||
:: --dry Dry-run mode (preview actions without executing)
|
||||
::
|
||||
:: examples:
|
||||
:: > myTask
|
||||
:: - Run the default task.
|
||||
:: > myTask --dry
|
||||
:: - Preview what the task would do without making changes.
|
||||
:: > myTask "C:\data\reports"
|
||||
:: - Run the task against a specific target directory.
|
||||
::
|
||||
set "_helpLinesMyTask=20"
|
||||
|
||||
:: ========================================================================
|
||||
:: TEMPLATE INSTRUCTIONS
|
||||
:: 1. Find/Replace "myTask" with your task name (camelCase).
|
||||
:: 2. Find/Replace "MyTask" with your task name (PascalCase).
|
||||
:: 3. Update the help block above (lines 2-20) for your task.
|
||||
:: 4. Implement your logic in :_runMyTask.
|
||||
:: 5. Add any new variables to :_removeBatchVariablesMyTask.
|
||||
:: ========================================================================
|
||||
|
||||
:: Config variables.
|
||||
set "_dryRunMyTask=0"
|
||||
set "_logFileMyTask=%TEMP%\%~n0.log"
|
||||
|
||||
:: Define paths.
|
||||
set "_scriptDirMyTask=%~dp0"
|
||||
set "_scriptNameMyTask=%~n0"
|
||||
|
||||
:: Parse arguments into variables.
|
||||
set "_parOneMyTask=%~1"
|
||||
set "_checkParOneMyTask=-%_parOneMyTask%-"
|
||||
set "_parTwoMyTask=%~2"
|
||||
set "_checkParTwoMyTask=-%_parTwoMyTask%-"
|
||||
|
||||
:: -----------------------------------------------------------------------
|
||||
:: Handle help flag.
|
||||
:: -----------------------------------------------------------------------
|
||||
if "%_parOneMyTask%"=="/?" call :_showHelpMyTask & goto _removeBatchVariablesMyTask
|
||||
if /i "%_parOneMyTask%"=="-h" call :_showHelpMyTask & goto _removeBatchVariablesMyTask
|
||||
if /i "%_parOneMyTask%"=="--help" call :_showHelpMyTask & goto _removeBatchVariablesMyTask
|
||||
|
||||
:: -----------------------------------------------------------------------
|
||||
:: Handle --dry flag (shift arguments if present).
|
||||
:: -----------------------------------------------------------------------
|
||||
if /i "%_parOneMyTask%"=="--dry" (
|
||||
set "_dryRunMyTask=1"
|
||||
set "_parOneMyTask=%~2"
|
||||
set "_checkParOneMyTask=-%~2-"
|
||||
)
|
||||
|
||||
:: Store current directory to return to after task completes.
|
||||
set "_savedDirMyTask=%CD%"
|
||||
|
||||
:: Create temp directory for intermediate files.
|
||||
call :_makeTempDirMyTask
|
||||
|
||||
:: -----------------------------------------------------------------------
|
||||
:: Log start and begin execution.
|
||||
:: -----------------------------------------------------------------------
|
||||
call :_logMyTask "=========================================="
|
||||
call :_logMyTask "Task started: %_scriptNameMyTask%"
|
||||
call :_logMyTask "=========================================="
|
||||
|
||||
call :_runMyTask
|
||||
|
||||
call :_logMyTask "Task finished: %_scriptNameMyTask%"
|
||||
goto _removeBatchVariablesMyTask
|
||||
|
||||
:: ========================================================================
|
||||
:: MAIN LOGIC
|
||||
:: ========================================================================
|
||||
|
||||
:_runMyTask
|
||||
REM ===================================================================
|
||||
REM TODO: Replace this section with your task logic.
|
||||
REM ===================================================================
|
||||
|
||||
if "%_dryRunMyTask%"=="1" (
|
||||
call :_logMyTask "[DRY RUN] Would process target: %_parOneMyTask%"
|
||||
goto :eof
|
||||
)
|
||||
|
||||
REM Example: Process files in a target directory.
|
||||
if NOT "%_checkParOneMyTask%"=="--" (
|
||||
if NOT EXIST "%_parOneMyTask%" (
|
||||
call :_logMyTask "ERROR: Target not found: %_parOneMyTask%"
|
||||
goto :eof
|
||||
)
|
||||
call :_logMyTask "Processing target: %_parOneMyTask%"
|
||||
REM Add task operations here.
|
||||
) else (
|
||||
call :_logMyTask "Running default task (no target specified)."
|
||||
REM Add default task operations here.
|
||||
)
|
||||
|
||||
call :_logMyTask "Task operations complete."
|
||||
goto :eof
|
||||
|
||||
:: ========================================================================
|
||||
:: SUPPORT FUNCTIONS
|
||||
:: ========================================================================
|
||||
|
||||
:_logMyTask
|
||||
REM Write a timestamped message to both console and log file.
|
||||
setlocal EnableDelayedExpansion
|
||||
for /f "tokens=2 delims==" %%a in ('wmic os get localdatetime /value') do (
|
||||
set "_dtMyTask=%%a"
|
||||
)
|
||||
set "_tsMyTask=!_dtMyTask:~0,4!-!_dtMyTask:~4,2!-!_dtMyTask:~6,2! !_dtMyTask:~8,2!:!_dtMyTask:~10,2!:!_dtMyTask:~12,2!"
|
||||
echo [!_tsMyTask!] %~1
|
||||
echo [!_tsMyTask!] %~1 >>"%_logFileMyTask%"
|
||||
endlocal
|
||||
goto :eof
|
||||
|
||||
:_showHelpMyTask
|
||||
echo:
|
||||
for /f "skip=1 tokens=* delims=" %%a in ('findstr /n "^" "%~f0"') do (
|
||||
set "_line=%%a"
|
||||
setlocal EnableDelayedExpansion
|
||||
set "_lineNum=!_line:~0,2!"
|
||||
if !_lineNum! GTR %_helpLinesMyTask% (
|
||||
endlocal
|
||||
goto :eof
|
||||
)
|
||||
set "_text=!_line:*:=!"
|
||||
if defined _text (
|
||||
echo !_text:~4!
|
||||
) else (
|
||||
echo:
|
||||
)
|
||||
endlocal
|
||||
)
|
||||
goto :eof
|
||||
|
||||
:_makeTempDirMyTask
|
||||
set "_tmpDirMyTask=%TEMP%\%~n0"
|
||||
if NOT EXIST "%_tmpDirMyTask%" (
|
||||
mkdir "%_tmpDirMyTask%" >nul 2>nul
|
||||
)
|
||||
goto :eof
|
||||
|
||||
:: ========================================================================
|
||||
:: CLEANUP - Remove all batch variables and restore directory.
|
||||
:: ========================================================================
|
||||
:_removeBatchVariablesMyTask
|
||||
set _helpLinesMyTask=
|
||||
set _dryRunMyTask=
|
||||
set _logFileMyTask=
|
||||
set _scriptDirMyTask=
|
||||
set _scriptNameMyTask=
|
||||
set _parOneMyTask=
|
||||
set _checkParOneMyTask=
|
||||
set _parTwoMyTask=
|
||||
set _checkParTwoMyTask=
|
||||
REM Append new variables above this line.
|
||||
|
||||
if EXIST "%_tmpDirMyTask%" rmdir /S /Q "%_tmpDirMyTask%" >nul 2>nul
|
||||
set _tmpDirMyTask=
|
||||
|
||||
REM Restore original directory.
|
||||
if DEFINED _savedDirMyTask (
|
||||
cd /D "%_savedDirMyTask%"
|
||||
set _savedDirMyTask=
|
||||
)
|
||||
exit /b
|
||||
Reference in New Issue
Block a user