How can I use IF EXIST with a specific file type?
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%DocumentsDolphin EmulatorConfigProfilesWiimote"
COPY "*.ini" "%USERPROFILE%DocumentsDolphin EmulatorConfigProfilesWiimote"
COPY "*.txt" "%USERPROFILE%DocumentsDolphin EmulatorConfigProfilesWiimote"
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%DocumentsDolphin EmulatorConfigProfilesWiimote"
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?
windows batch-file
|
show 2 more comments
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%DocumentsDolphin EmulatorConfigProfilesWiimote"
COPY "*.ini" "%USERPROFILE%DocumentsDolphin EmulatorConfigProfilesWiimote"
COPY "*.txt" "%USERPROFILE%DocumentsDolphin EmulatorConfigProfilesWiimote"
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%DocumentsDolphin EmulatorConfigProfilesWiimote"
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?
windows batch-file
TryIF EXIST "*.ini"
. Try also with the folder path.
– harrymc
Feb 1 at 13:12
I already tried wrapping the extension definiton in quotes @harrymc, no dice.
– Mr. Mendelli
Feb 1 at 13:14
1
Your above lines do work here, without seeing your compplete code it's difficult to help. Without a path it checks the current folder, not neccessarily the one the batch resides in.
– LotPings
Feb 1 at 13:25
I'm checking the working directory @LotPings (`.`). I tried using the path variable as well but it changed nothing. This is just an initial check I'm running in my script.
– Mr. Mendelli
Feb 1 at 13:51
1
It's IMO still unclear where you want to check for the *.ini files, in case you want to refer to the same folder where the batch file is, useIf exist "%~dp0*.ini" GOTO :IMPORT
– LotPings
Feb 8 at 22:30
|
show 2 more comments
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%DocumentsDolphin EmulatorConfigProfilesWiimote"
COPY "*.ini" "%USERPROFILE%DocumentsDolphin EmulatorConfigProfilesWiimote"
COPY "*.txt" "%USERPROFILE%DocumentsDolphin EmulatorConfigProfilesWiimote"
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%DocumentsDolphin EmulatorConfigProfilesWiimote"
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?
windows batch-file
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%DocumentsDolphin EmulatorConfigProfilesWiimote"
COPY "*.ini" "%USERPROFILE%DocumentsDolphin EmulatorConfigProfilesWiimote"
COPY "*.txt" "%USERPROFILE%DocumentsDolphin EmulatorConfigProfilesWiimote"
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%DocumentsDolphin EmulatorConfigProfilesWiimote"
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?
windows batch-file
windows batch-file
edited Feb 11 at 3:46
Mr. Mendelli
asked Feb 1 at 12:49
Mr. MendelliMr. Mendelli
594520
594520
TryIF EXIST "*.ini"
. Try also with the folder path.
– harrymc
Feb 1 at 13:12
I already tried wrapping the extension definiton in quotes @harrymc, no dice.
– Mr. Mendelli
Feb 1 at 13:14
1
Your above lines do work here, without seeing your compplete code it's difficult to help. Without a path it checks the current folder, not neccessarily the one the batch resides in.
– LotPings
Feb 1 at 13:25
I'm checking the working directory @LotPings (`.`). I tried using the path variable as well but it changed nothing. This is just an initial check I'm running in my script.
– Mr. Mendelli
Feb 1 at 13:51
1
It's IMO still unclear where you want to check for the *.ini files, in case you want to refer to the same folder where the batch file is, useIf exist "%~dp0*.ini" GOTO :IMPORT
– LotPings
Feb 8 at 22:30
|
show 2 more comments
TryIF EXIST "*.ini"
. Try also with the folder path.
– harrymc
Feb 1 at 13:12
I already tried wrapping the extension definiton in quotes @harrymc, no dice.
– Mr. Mendelli
Feb 1 at 13:14
1
Your above lines do work here, without seeing your compplete code it's difficult to help. Without a path it checks the current folder, not neccessarily the one the batch resides in.
– LotPings
Feb 1 at 13:25
I'm checking the working directory @LotPings (`.`). I tried using the path variable as well but it changed nothing. This is just an initial check I'm running in my script.
– Mr. Mendelli
Feb 1 at 13:51
1
It's IMO still unclear where you want to check for the *.ini files, in case you want to refer to the same folder where the batch file is, useIf exist "%~dp0*.ini" GOTO :IMPORT
– LotPings
Feb 8 at 22:30
Try
IF EXIST "*.ini"
. Try also with the folder path.– harrymc
Feb 1 at 13:12
Try
IF EXIST "*.ini"
. Try also with the folder path.– harrymc
Feb 1 at 13:12
I already tried wrapping the extension definiton in quotes @harrymc, no dice.
– Mr. Mendelli
Feb 1 at 13:14
I already tried wrapping the extension definiton in quotes @harrymc, no dice.
– Mr. Mendelli
Feb 1 at 13:14
1
1
Your above lines do work here, without seeing your compplete code it's difficult to help. Without a path it checks the current folder, not neccessarily the one the batch resides in.
– LotPings
Feb 1 at 13:25
Your above lines do work here, without seeing your compplete code it's difficult to help. Without a path it checks the current folder, not neccessarily the one the batch resides in.
– LotPings
Feb 1 at 13:25
I'm checking the working directory @LotPings (`.`). I tried using the path variable as well but it changed nothing. This is just an initial check I'm running in my script.
– Mr. Mendelli
Feb 1 at 13:51
I'm checking the working directory @LotPings (`.`). I tried using the path variable as well but it changed nothing. This is just an initial check I'm running in my script.
– Mr. Mendelli
Feb 1 at 13:51
1
1
It's IMO still unclear where you want to check for the *.ini files, in case you want to refer to the same folder where the batch file is, use
If exist "%~dp0*.ini" GOTO :IMPORT
– LotPings
Feb 8 at 22:30
It's IMO still unclear where you want to check for the *.ini files, in case you want to refer to the same folder where the batch file is, use
If exist "%~dp0*.ini" GOTO :IMPORT
– LotPings
Feb 8 at 22:30
|
show 2 more comments
1 Answer
1
active
oldest
votes
I think that you can use following command
SET IS-PROFILE=NO
FOR %%f IN (*.ini) do SET IS-PROFILE=YES
and then test IS-PROFILE
As proposed in comment, you can break the loop using following command
SET IS-PROFILE==NO
FOR %%f IN (*.ini) do (
set IS-PROFILE=YES
echo %%f - File containing INI exists
exit /b
)
IF '%IS-PROFILE%'=='NO' (
echo NO File contains INI type
)
I have tested on my PC on Windows 10 and this work fine.
1
instead of looping through all the files you can just set the variable and break early, or jump to a place that contains the "exist" branch
– phuclv
Feb 1 at 14:02
1
Yes, but breaking a FOR loop in DOS is tricky
– schlebe
Feb 1 at 14:20
1
the OP is using Windows, not DOS, and in cmd there are many ways to exit a for loop. It's often used to get the first result in a list or the first line in a text filefile. Exiting out of a FOR loop in a batch file?
– phuclv
Feb 1 at 14:37
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1400976%2fhow-can-i-use-if-exist-with-a-specific-file-type%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think that you can use following command
SET IS-PROFILE=NO
FOR %%f IN (*.ini) do SET IS-PROFILE=YES
and then test IS-PROFILE
As proposed in comment, you can break the loop using following command
SET IS-PROFILE==NO
FOR %%f IN (*.ini) do (
set IS-PROFILE=YES
echo %%f - File containing INI exists
exit /b
)
IF '%IS-PROFILE%'=='NO' (
echo NO File contains INI type
)
I have tested on my PC on Windows 10 and this work fine.
1
instead of looping through all the files you can just set the variable and break early, or jump to a place that contains the "exist" branch
– phuclv
Feb 1 at 14:02
1
Yes, but breaking a FOR loop in DOS is tricky
– schlebe
Feb 1 at 14:20
1
the OP is using Windows, not DOS, and in cmd there are many ways to exit a for loop. It's often used to get the first result in a list or the first line in a text filefile. Exiting out of a FOR loop in a batch file?
– phuclv
Feb 1 at 14:37
add a comment |
I think that you can use following command
SET IS-PROFILE=NO
FOR %%f IN (*.ini) do SET IS-PROFILE=YES
and then test IS-PROFILE
As proposed in comment, you can break the loop using following command
SET IS-PROFILE==NO
FOR %%f IN (*.ini) do (
set IS-PROFILE=YES
echo %%f - File containing INI exists
exit /b
)
IF '%IS-PROFILE%'=='NO' (
echo NO File contains INI type
)
I have tested on my PC on Windows 10 and this work fine.
1
instead of looping through all the files you can just set the variable and break early, or jump to a place that contains the "exist" branch
– phuclv
Feb 1 at 14:02
1
Yes, but breaking a FOR loop in DOS is tricky
– schlebe
Feb 1 at 14:20
1
the OP is using Windows, not DOS, and in cmd there are many ways to exit a for loop. It's often used to get the first result in a list or the first line in a text filefile. Exiting out of a FOR loop in a batch file?
– phuclv
Feb 1 at 14:37
add a comment |
I think that you can use following command
SET IS-PROFILE=NO
FOR %%f IN (*.ini) do SET IS-PROFILE=YES
and then test IS-PROFILE
As proposed in comment, you can break the loop using following command
SET IS-PROFILE==NO
FOR %%f IN (*.ini) do (
set IS-PROFILE=YES
echo %%f - File containing INI exists
exit /b
)
IF '%IS-PROFILE%'=='NO' (
echo NO File contains INI type
)
I have tested on my PC on Windows 10 and this work fine.
I think that you can use following command
SET IS-PROFILE=NO
FOR %%f IN (*.ini) do SET IS-PROFILE=YES
and then test IS-PROFILE
As proposed in comment, you can break the loop using following command
SET IS-PROFILE==NO
FOR %%f IN (*.ini) do (
set IS-PROFILE=YES
echo %%f - File containing INI exists
exit /b
)
IF '%IS-PROFILE%'=='NO' (
echo NO File contains INI type
)
I have tested on my PC on Windows 10 and this work fine.
edited Feb 1 at 18:18
answered Feb 1 at 13:39
schlebeschlebe
13310
13310
1
instead of looping through all the files you can just set the variable and break early, or jump to a place that contains the "exist" branch
– phuclv
Feb 1 at 14:02
1
Yes, but breaking a FOR loop in DOS is tricky
– schlebe
Feb 1 at 14:20
1
the OP is using Windows, not DOS, and in cmd there are many ways to exit a for loop. It's often used to get the first result in a list or the first line in a text filefile. Exiting out of a FOR loop in a batch file?
– phuclv
Feb 1 at 14:37
add a comment |
1
instead of looping through all the files you can just set the variable and break early, or jump to a place that contains the "exist" branch
– phuclv
Feb 1 at 14:02
1
Yes, but breaking a FOR loop in DOS is tricky
– schlebe
Feb 1 at 14:20
1
the OP is using Windows, not DOS, and in cmd there are many ways to exit a for loop. It's often used to get the first result in a list or the first line in a text filefile. Exiting out of a FOR loop in a batch file?
– phuclv
Feb 1 at 14:37
1
1
instead of looping through all the files you can just set the variable and break early, or jump to a place that contains the "exist" branch
– phuclv
Feb 1 at 14:02
instead of looping through all the files you can just set the variable and break early, or jump to a place that contains the "exist" branch
– phuclv
Feb 1 at 14:02
1
1
Yes, but breaking a FOR loop in DOS is tricky
– schlebe
Feb 1 at 14:20
Yes, but breaking a FOR loop in DOS is tricky
– schlebe
Feb 1 at 14:20
1
1
the OP is using Windows, not DOS, and in cmd there are many ways to exit a for loop. It's often used to get the first result in a list or the first line in a text filefile. Exiting out of a FOR loop in a batch file?
– phuclv
Feb 1 at 14:37
the OP is using Windows, not DOS, and in cmd there are many ways to exit a for loop. It's often used to get the first result in a list or the first line in a text filefile. Exiting out of a FOR loop in a batch file?
– phuclv
Feb 1 at 14:37
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1400976%2fhow-can-i-use-if-exist-with-a-specific-file-type%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try
IF EXIST "*.ini"
. Try also with the folder path.– harrymc
Feb 1 at 13:12
I already tried wrapping the extension definiton in quotes @harrymc, no dice.
– Mr. Mendelli
Feb 1 at 13:14
1
Your above lines do work here, without seeing your compplete code it's difficult to help. Without a path it checks the current folder, not neccessarily the one the batch resides in.
– LotPings
Feb 1 at 13:25
I'm checking the working directory @LotPings (`.`). I tried using the path variable as well but it changed nothing. This is just an initial check I'm running in my script.
– Mr. Mendelli
Feb 1 at 13:51
1
It's IMO still unclear where you want to check for the *.ini files, in case you want to refer to the same folder where the batch file is, use
If exist "%~dp0*.ini" GOTO :IMPORT
– LotPings
Feb 8 at 22:30