Batch File For Running JsDoc Toolkit

Just released today, I've written a batch file to automate running the JsDoc Toolkit. When running the batch file you may supply the path to your JavaScript source files and have it automatically run the toolkit or, you may run the batch file with no arguments and it will ask you for the location of your source files. Mostly, I wrote this so I could run the JsDoc Toolkit from my favorite text editor Notepad++ but, it would work equally as well in any IDE that lets you run external files. You can download it and find out more at https://code.google.com/p/batch-file-to-run-jsdoc-toolkit/

jsrun.bat

@echo off
SET jsdocToolkitLoc=%~dp0

:findJsdocToolkitLoc
IF NOT EXIST "%jsdocToolkitLoc%jsrun.jar" (
SET /P jsdocToolkitLoc=[Enter the full path to jsrun.jar including trailing backslash]
GOTO findJsdocToolkitLoc
)

SET jsdocTemplateLoc=%jsdocToolkitLoc%templates\jsdoc
SET jsdocRunJsLoc=%jsdocToolkitLoc%app\run.js
SET jsdocJsRunLoc=%jsdocToolkitLoc%jsrun.jar

IF "%~1"=="" (
SET /P src=[Enter the full path to your source folder without trailing backslash]
) ELSE (
SET src=%~1
)
SET docsOutputDir=%src%\..\docs\jsdoc
SET jsdocLogOutputDir=%src%\..\logs
SET jsdocLogFileName=jsdoc-toolkit-error-log.txt
SET jsdocLogOutput=%jsdocLogOutputDir%\%jsdocLogFileName%

IF EXIST "%jsdocLogOutput%" (
DEL /F /Q "%jsdocLogOutput%"
)
IF EXIST "%docsOutputDir%" (
RMDIR /S /Q "%docsOutputDir%"
)
IF NOT EXIST "%jsdocLogOutputDir%" (
MKDIR "%jsdocLogOutputDir%"
)

java -jar "%jsdocJsRunLoc%" "%jsdocRunJsLoc%" -a -p -d="%docsOutputDir%" -o="%jsdocLogOutput%" -t="%jsdocTemplateLoc%" "%src%"

echo Errors, if any, have been logged to %jsdocLogOutput%
pause


Usage

jsrun.bat "C:\path\to\src" or jsrun.bat.

newJsProject.bat

The purpose of this batch file is to quickly generate a useful folder structure for JavaScript projects. This folder structure is what jsrun.bat expects to be dealing with. You may alter both of these files if you would like to generate a different folder structure for your projects. This batch file will ask you for a path, the last folder listed in the path being the top level of your project. Inside the top level folder it will create three sibling folders named src, docs, and logs.

@echo off
IF "%~1"=="" (
SET /P projectName=[Enter the full path including the name of your project]
) ELSE (
SET projectName=%~1
)
IF EXIST %projectName% (
pause
goto end
)
FOR %%A IN ("%projectName%","%projectName%\src","%projectName%\docs","%projectName%\logs") DO (
IF NOT EXIST %%A (
MKDIR %%A
)
)
:end


Usage

newJsProject.bat "C:\path\to\project\project name" or newJsProject.bat.