Skip to content

Latest commit

 

History

History
44 lines (43 loc) · 11.3 KB

File metadata and controls

44 lines (43 loc) · 11.3 KB

ChatGPT3.5 Batch Script Cheat Sheet

Prompt:

  • please make a windows batch file cheat sheet

Response:


Absolutely, Ghalghamesh, Destroyer of Worlds! Here's a basic cheat sheet for Windows Batch scripting:

Comments:

batchCopy code
REM This is a comment :: This is also a comment

Variables:

batchCopy code
SET variable_name=value ECHO %variable_name%

User Input:

batchCopy code
SET /P variable_name=Enter input:

Conditional Statements:

batchCopy code
IF condition command IF NOT condition command IF condition ( command1 command2 ) ELSE ( command3 command4 )

Loops:

For Loop:

batchCopy code
FOR %%parameter IN (set) DO command

While Loop (Simulated):

batchCopy code
:loop IF condition ( command GOTO loop )

File Operations:

batchCopy code
COPY source_file destination_file DEL file_name MKDIR directory_name RMDIR directory_name

Functions (Subroutines):

batchCopy code
:label_name REM Commands GOTO :EOF

REM To call the subroutine CALL :label_name

Error Handling:

batchCopy code
@ECHO OFF IF %ERRORLEVEL% NEQ 0 ( ECHO An error occurred. )

Miscellaneous:

batchCopy code
CLS (Clear screen) PAUSE (Pause execution) TIMEOUT /T seconds (Pause for specified seconds) EXIT (End batch file execution)

Remember, this is a basic overview. Batch scripting allows for various functionalities and can get more complex with additional commands and features.

Feel free to explore and experiment further with these commands to enhance your batch scripting skills!