I'm trying to make a batch script that will perfotm one of two actions based on if a specified filetype is or is not present. I'm using If EXIST
and IF NOT EXIST
, but I can't get these to actually detect if the file type exists or not. Here's my code:
@ECHO OFF
IF NOT EXIST *.ini GOTO :NOPROFILE
IF EXIST *.ini GOTO :IMPORT
:INSTALL
COLOR 0B
TITLE Profile Installer
MODE CON COLS=43 LINES=2
cls
SET /P MENU="Do you want to install this profile (Y/N)? "
IF /I "%MENU%" EQU "Y" GOTO :IMPORT
IF /I "%MENU%" EQU "N" GOTO :CANCELLED
IF /I "%MENU%" EQU "Y" GOTO :INVALID
IF /I "%MENU%" NEQ "N" GOTO :INVALID
:IMPORT
MKDIR "%USERPROFILE%\Documents\Dolphin Emulator\Config\Profiles\Wiimote"
COPY "*.ini" "%USERPROFILE%\Documents\Dolphin Emulator\Config\Profiles\Wiimote"
COPY "*.txt" "%USERPROFILE%\Documents\Dolphin Emulator\Config\Profiles\Wiimote"
GOTO :DONE
:INVALID
CLS
SET msgboxTitle=Error!
SET msgboxBody=Please enter one of the above menu options...
SET tmpmsgbox=%TEMP%\Message.vbs
IF EXIST "%tmpmsgbox%" DEL /F /Q "%tmpmsgbox%"
ECHO msgbox "%msgboxBody%",0,"%msgboxTitle%">"%tmpmsgbox%"
Error.exe "%tmpmsgbox%"
GOTO :INSTALL
:DONE
CLS
SET msgboxTitle=Notice
SET msgboxBody=The profile has been successfully installed.
SET tmpmsgbox=%TEMP%\Message.vbs
IF EXIST "%tmpmsgbox%" DEL /F /Q "%tmpmsgbox%"
ECHO msgbox "%msgboxBody%",0,"%msgboxTitle%">"%tmpmsgbox%"
Error.exe "%tmpmsgbox%"
GOTO :OPEN
:OPEN
%SYSTEMROOT%\explorer.exe "%USERPROFILE%\Documents\Dolphin Emulator\Config\Profiles\Wiimote"
GOTO :END
:CANCELLED
CLS
SET msgboxTitle=Notice
SET msgboxBody=Installation cancelled, closing...
SET tmpmsgbox=%TEMP%\Message.vbs
IF EXIST "%tmpmsgbox%" DEL /F /Q "%tmpmsgbox%"
ECHO msgbox "%msgboxBody%",0,"%msgboxTitle%">"%tmpmsgbox%"
Error.exe "%tmpmsgbox%"
GOTO :END
:NOPROFILE
CLS
SET msgboxTitle=Error!
SET msgboxBody=No INI profile detected, closing...
SET tmpmsgbox=%TEMP%\Message.vbs
IF EXIST "%tmpmsgbox%" DEL /F /Q "%tmpmsgbox%"
ECHO msgbox "%msgboxBody%",0,"%msgboxTitle%">"%tmpmsgbox%"
Error.exe "%tmpmsgbox%"
GOTO :END
:END
Is this possible, how do I achieve my goal by declaring a specific file type or extension?
IF EXIST "*.ini"
. Try also with the folder path.If exist "%~dp0*.ini" GOTO :IMPORT