ℹ️ Select 'Choose Exercise', or randomize 'Next Random Exercise' in selected language.

Choose Exercise:
Timer 00:00
WPM --
Score --
Acc --
Correct chars --

Basic Environment Setup Script

Batch

Goal -- WPM

Ready
Exercise Algorithm Area
1@echo off
2
3REM Configuration
4set PROJECT_NAME=MyNewProject
5set BASE_DIR=C:\Projects
6
7REM --- Main Logic ---
8
9echo Setting up environment for project: %PROJECT_NAME%
10
11REM Define the full project path
12set PROJECT_PATH=%BASE_DIR%\%PROJECT_NAME%
13
14REM Create the base directory if it doesn't exist
15if not exist "%BASE_DIR%" (
16echo Creating base directory: %BASE_DIR%
17mkdir "%BASE_DIR%"
18if errorlevel 1 (
19echo Failed to create base directory. Aborting.
20goto :EOF
21)
22)
23
24REM Create the project directory
25echo Creating project directory: %PROJECT_PATH%
26mkdir "%PROJECT_PATH%"
27if errorlevel 1 (
28echo Failed to create project directory. Aborting.
29goto :EOF
30)
31
32REM Create placeholder files
33echo Creating placeholder files...
34
35REM Create a main script file
36echo. > "%PROJECT_PATH%\main.bat"
37echo echo "Hello from %PROJECT_NAME%!" > "%PROJECT_PATH%\main.bat"
38
39REM Create a configuration file
40echo. > "%PROJECT_PATH%\config.ini"
41
42REM Create a readme file
43echo. > "%PROJECT_PATH%\README.md"
44
45echo Environment setup complete for project: %PROJECT_NAME%
46goto :EOF
Algorithm description viewbox

Basic Environment Setup Script

Algorithm description:

This script automates the initial setup of a new development project. It creates a dedicated directory for the project and then generates essential placeholder files like a main script, a configuration file, and a README. This saves time and ensures a consistent starting point for new projects.

Algorithm explanation:

The script uses basic batch commands to create directories and files. It first defines configuration variables for the project name and base directory. It then checks if the base directory exists and creates it if necessary. Subsequently, it creates the specific project directory. Finally, it uses the `echo.` command to create empty files and `echo "..." > filename` to write initial content into them. Error checking is included after `mkdir` commands to ensure directories are created successfully. This scenario is ideal for practicing fundamental batch commands for file and directory manipulation.

Pseudocode:

1. Define configuration variables: project name, base directory.
2. Construct the full project path.
3. Check if the base directory exists; if not, create it and handle errors.
4. Create the project directory and handle errors.
5. Create placeholder files:
   a. Create an empty main script file (e.g., main.bat).
   b. Create an empty configuration file (e.g., config.ini).
   c. Create an empty README file (e.g., README.md).
6. Print a completion message.