I’m trying to create a batch file that will check the existence of a directory before processing the rest of the commands. The directory name will always start the same, but then various numbers and sometimes letters are appended to the end. I would like to delete the directory at the end of the batch file, but using variables with rmdir without checking to make sure that path exists first has created issues (as in another directory being deleted). The code below is what I’ve been working with, but the system says this path doesn’t exist.
IF EXIST "C:\Today's Unique Folder*\nul" ( GOTO continue ) ELSE ( GOTO end)
Furthermore, I tried to set this path as a variable and use the variable with IF EXIST, but that didn’t work either. Is there a command other than IF EXIST that I should try? Thanks in advance for the assistance.
You can use
FORwith the/Dparameter to search for the folder name using a wildcard.Note, if there are multiple folders found with the same beginning part of the folder name,
RESULTwill end up being the last folder.