Reputation: 741
I am trying to make a bat file that will grab a git repository and download it to a specific directory.
The error I get when running this script is:
' was unexpected at this time.
Here is my code:
@echo off
TITLE Starter Kit
cls
echo "Note: This script will download the 'CodeKit-Starter-Kit' repository from @NicholasAdamou's GitHub."
set /p response="Do you want to continue? <y/n>"
if /i "%response%"=="y" (
goto :downloadKit
:downloadKit
cls
echo "Downloading the CodeKit-Starter-Kit repository from @NicholasAdamou's GitHub."
set "filePath=%~dp0"
cd %filePath%
cd ../dist
git clone https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git 'StarterKit (CodeKit)'
)
if /i "%response%"=="n" (
call exit
)
Upvotes: 0
Views: 109
Reputation: 3471
You need to escape the parenthesis of the git line, like this:
git clone https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git 'StarterKit (CodeKit^)'
This is because batch views closing parenthesis as special characters
Upvotes: 2
Reputation: 408
I don't understand set "filePath=%~dp0"
Try to substitute single quotes in git command with doublequotes .
Anyway , we are in 2016 , it's time to learn powershell :-)
$filepath="$home\\dp0"
read-host -prompt "Do you want download it ? " -outvariable response
if ( $response -eq "y"){
set-location "$filepath\\dist"
git clone https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git 'StarterKit (CodeKit)'
}
Upvotes: 0