I am working with a batch script in which the user can automate the creation of folders and subfolders on windows.
Here's the actual code:
@echo off
:: MAKES A TEMPORARY FOLDER FIRST
mkdir "New Folder 123"
:: LET THE USER INPUT PREFERED FOLDER NAME AND THIS WILL CHANGE THE TEMPORARY INTO THE NEW ONE
:rename
cls
SET /p comm=Please enter your prefered folder name:
IF /i "%comm%" == "%comm%" ren "New Folder 123" "%comm%"
IF /i "" == "%comm%" goto :rename
IF /i " " == "%comm%" goto :rename
:: COMMAND WILL OPEN THE NEWLY RENAMED FOLDER AND CREATES SUBFOLDER(S)
cd "%comm%"
md "Folder 1" "Folder 2"
exit
Now, the problem is... If the user accidentally exits the command prompt window, the temporary folder which I initially wrote from the beginning of the code remains.
:: MAKES A TEMPORARY FOLDER FIRST
mkdir "New Folder 123"
This will create a conflict if the user runs the batch script the second time since that temporary folder already exists and I don't want the user to manually right click and delete it cause that would be a hassle.
So I'm hoping if anyone could provide a code that will automatically delete the initial folder as the user (accidentally) exits the console? I've been looking for similar solutions here that are closely related to mine, but they all seems to delete the batch file itself instead of a folder, I'm also really new into making programs and I had a hard time understanding some batch codes, so please be easy with me, Any help would be greatly appreciated, Thank you so much everyone.