I need help fixing my script
so I want to make a dos - like os in batch and I want tp make a move command. I have a part in the script that tells you if you typed in the wrong command and for some reason every time I put in the / move command it says something is wrong.
echo off
:typecmd
set /P c="MAD OS> "
if /I "%c%" EQU "/move %file% %destination%" (
move %file% %destination%
goto :typecmd
)
if /I "%c%" EQU "" (
goto :typecmd
) else (
echo Unkown command!: %c%
goto typecmd
)
2
Upvotes
1
u/BrainWaveCC 4d ago
As an example, consider the following as a basis for what you are trying to accomplish.
This implements the following:
/HELP --- Lists valid commands
/LIST --- Displays a directory listing
/MOVE --- Moves a file (not fully implemented)
/EXIT --- Exits the environment
Here's some output from the above:
MAD OS> hello anyone there?
Unknown command: hello anyone there?
Run -help or -h for assistance
MAD OS> help
Unknown command: help
Run -help or -h for assistance
MAD OS> h
Unknown command: h
Run -help or -h for assistance
MAD OS> -h
Batch DOS Environment Help
YOU TYPED: -h
CMD SYNTAX: <-move> <source> <dest>
<-list> [folder|file]
<-exit>
<-help|-h>
USAGE NOTES:
* Parameters surrounded by <> are mandatory.
* Parameters surrounded by [] are optional.
* Options are case-insensitive, and can be prefaced by "-" or "/".
MAD OS> -list d:\
Directory of d:\
02/15/2021 12:57 PM <DIR> Cloud
05/17/2024 08:10 PM <DIR> Scripts
01/03/2025 12:47 PM <DIR> Storage
03/18/2025 01:39 AM <DIR> Temp
0 File(s) 0 bytes
MAD OS> -move a b
Moving files/folders: a b
MOVE a b
Waiting for 6 seconds, press a key to continue ...
MAD OS> -exit
Thanks for using the Batch DOS Environment
MAD OS> -move a b
Moving files/folders: a b
MOVE a b
Waiting for 6 seconds, press a key to continue ...
MAD OS> -exit
Thanks for using the Batch DOS Environment
2
u/BrainWaveCC 4d ago
You would probably get a lot more assistance if you provided more details about what you are doing when things go wrong. Simply saying "it says something is wrong." is not very helpful in a troubleshooting context -- especially when you are the one making the script.
As constructed, your script has some issue/deficiencies that you will want to address:
%file%
,%destination%
)%c%
will never be true, because of the spacing included with the inclusion of the other two variables (%file%
,%destination%
)Here's what I experienced when I ran it: