You need to write a batch file in Windows (in case of Linux they are called shell script). It is very easy to write once you know what commands to use (In your case you already know the commands). In a batch file you need to write down the commands in the order in which you want them to execute. To create a batch file, open a Notepad and write down those commands in order and save the file with .bat extension. Next you just need to double click that .bat file and it will do all your task. Just giving you an example of how your batch file should look like.
cd /your/working/directory/path
jekyll s
start chrome "http://localhost:4000/"
Basic input/output operation in batch file
Taking input from the user: [Command used set
]
Syntax: set /p variable_name=[Prompt String]
Example: set /p loc="Enter the directory path : "
This will prompt for an input from the user and will assign it to the variable loc
.
Displaying message/output on the screen: [Command used echo
]
Syntax: echo <your_message_here>
Example: echo Hello World
Will display "Hello World" on the screen. To print the content of a variable using echo
use echo %variable_name%
. Say you want to display the content of the variable my_name
. Then the command will be echo Hello %my_name%
.
Making your script more interactive using these commands.
echo off
::The above command hides the commands that are executed and displays only the output of the commands
set /p loc="Enter your project directory location : "
cd /d %loc%
echo Directory changed...
jekyll s
echo Launching browser...
start chrome "http://localhost:4000/"
echo End of script...
pause
::
is used for commenting. To know more about a particular command use /?
after the command name to display the manual for that command which contains what the command does and all the options that are available for it. For example to know more about the cd
command enter cd /?
in the prompt.
Here is a nice tutorial for beginners.
1Thank you for your answer, I just had the time to look at it and I made my batch file. Do you have any suggestions for a beginners guide to windows scripting? Would be awesome if you included that in your answer as well:) – Varaquilex – 2015-04-27T14:17:36.677
@Varaquilex welcome. :)
Certainly, I will add some more info about batch files to the answer if that would help you. I will update the answer whenever I get some time but if you need something specific feel free to mention it and I will update it accordingly. – Ayan – 2015-04-27T14:31:23.423
Just the standard basics would do for now, thanks^^ – Varaquilex – 2015-04-27T14:33:42.253