DIR command that ignores files with multiple extensionsHow to use regex quantifiers to rename multiple files...
Wardrobe above a wall with fuse boxes
Why doesn't "adolescent" take any articles in "listen to adolescent agonising"?
What does each site of a vanilla 9.1 installation do?
Can metaphors be used for other purposes than for stylistic effect and to form an allegory?
Are there other characters in the Star Wars universe who had damaged bodies and needed to wear an outfit like Darth Vader?
Can an earth elemental drown/bury its opponent underground using earth glide?
3.5% Interest Student Loan or use all of my savings on Tuition?
Four buttons on a table
What is the meaning of "notice to quit at once" and "Lotty points”
How does signal strength relate to bandwidth?
Create chunks from an array
Is there a limit on the maximum number of future jobs queued in an org?
Why would the IRS ask for birth certificates or even audit a small tax return?
Draw bounding region by list of points
Relationship between the symmetry number of a molecule as used in rotational spectroscopy and point group
1970s scifi/horror novel where protagonist is used by a crablike creature to feed its larvae, goes mad, and is defeated by retraumatising him
Would the melodic leap of the opening phrase of Mozart's K545 be considered dissonant?
Can a space-faring robot still function over a billion years?
Being asked to review a paper in conference one has submitted to
Where is the fallacy here?
How can I handle a player who pre-plans arguments about my rulings on RAW?
Is there a frame of reference in which I was born before I was conceived?
How do you say “my friend is throwing a party, do you wanna come?” in german
How can I be pwned if I'm not registered on the compromised site?
DIR command that ignores files with multiple extensions
How to use regex quantifiers to rename multiple files with zmv?DIR filenames that contain extensionsHow can I copy identically-named files out of a series of folders, and append the folder name to the filename to disambiguate?Windows wildcards with files having more than 3 characters extensionsCommand Line : Concatenate multiple files by dateCopy the most recent of two files with Windows command linedel with cmd a file from dir if it exists in another dirHow can I keep the dir command date/time from changing?dir command - search for file names with partial string and file extensionUsing multiple wildcards to select files of specific extension type with specific letters in their name
I have a directory containing a single .exe that I need to find using DIR. However, I also have files in the same directory that end in .vshost.exe.
I always end up with both files matched to my *.exe pattern.
i.e the directory contains test.exe and test.vshost.exe (both files have the same name minus the extension.)
How can I match just the .exe, and not .vshost.exe? I feel like this should be relatively easy using * and ? but I can't seem to find much about excluding a file like this. Thanks.
windows command-line batch-file dir
New contributor
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I have a directory containing a single .exe that I need to find using DIR. However, I also have files in the same directory that end in .vshost.exe.
I always end up with both files matched to my *.exe pattern.
i.e the directory contains test.exe and test.vshost.exe (both files have the same name minus the extension.)
How can I match just the .exe, and not .vshost.exe? I feel like this should be relatively easy using * and ? but I can't seem to find much about excluding a file like this. Thanks.
windows command-line batch-file dir
New contributor
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I have a directory containing a single .exe that I need to find using DIR. However, I also have files in the same directory that end in .vshost.exe.
I always end up with both files matched to my *.exe pattern.
i.e the directory contains test.exe and test.vshost.exe (both files have the same name minus the extension.)
How can I match just the .exe, and not .vshost.exe? I feel like this should be relatively easy using * and ? but I can't seem to find much about excluding a file like this. Thanks.
windows command-line batch-file dir
New contributor
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have a directory containing a single .exe that I need to find using DIR. However, I also have files in the same directory that end in .vshost.exe.
I always end up with both files matched to my *.exe pattern.
i.e the directory contains test.exe and test.vshost.exe (both files have the same name minus the extension.)
How can I match just the .exe, and not .vshost.exe? I feel like this should be relatively easy using * and ? but I can't seem to find much about excluding a file like this. Thanks.
windows command-line batch-file dir
windows command-line batch-file dir
New contributor
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked yesterday
610163610163
184
184
New contributor
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
610163 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
This is unfortunately not possible with only the DIR command, however it can be combined with the FINDSTR command.
I'm focusing on the more general question, rather than the specific question regarding .exe files, but you can easily modify this to narrow it down.
The FINDSTR command supports regular expression searches on the output which allows us to filter out files with more than one period in the filename.
DIR /B | FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"
I would suggest wrapping into a FOR loop as follows to do something with the returned file list:
FOR /F "tokens=*" %%a IN ('DIR /B ^| FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"') DO ECHO %%a
Breakdown
In this explanation, <...> is a placeholder for things that will be explained later. It's only there to simplify.
FOR /F "tokens=*" %%a IN ('<...>') DO ECHO %%a
Using"tokens=*"or"delims="in yourFORloop allows processing filenames with spaces. ReplaceECHO %%awith whatever command(s) you want to run.
DIR /B
Using the/Bswitch on theDIRcommand uses bare format, including only the filenames. This is required for theFINDSTRcommand to function as we want.
^|
It is important to escape the|character when used inside the command portion of aFORloop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incompleteFORloop into something else.
FINDSTR /V /R "<...>"
The/Vswitch tellsFINDSTRto remove matches from the list and the/Rswitch turns on Regular Expression mode.
[^.]*.[^.]*.[^.]*$
[^.]*will match any string of characters that do not include the.character.
.will match the.character.
$is the "end of line" character, meaning that this regular expression must be at the end of the filename. This allows us to match files with any number of periods in the filename such astest.vhost.exe.bak.
Further Reading
- Dir - SS64.com
- Findstr - SS64.com
- For (command) - SS64.com
add a comment |
this should work:
dir *.exe /b | findstr /i ".*[^.]*.*.exe$"
in words: find a string in .exe files that does not contain a dot other than the one in .exe
2
Consider adding a note explaining why this might work if you want to make it even more helpful.
– Pimp Juice IT
yesterday
3
The two.*in the pattern will allow any number of literal dots, and the class[^*.]without a quantifier is pretty useless.
– LotPings
yesterday
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
});
}
});
610163 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1411501%2fdir-command-that-ignores-files-with-multiple-extensions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is unfortunately not possible with only the DIR command, however it can be combined with the FINDSTR command.
I'm focusing on the more general question, rather than the specific question regarding .exe files, but you can easily modify this to narrow it down.
The FINDSTR command supports regular expression searches on the output which allows us to filter out files with more than one period in the filename.
DIR /B | FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"
I would suggest wrapping into a FOR loop as follows to do something with the returned file list:
FOR /F "tokens=*" %%a IN ('DIR /B ^| FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"') DO ECHO %%a
Breakdown
In this explanation, <...> is a placeholder for things that will be explained later. It's only there to simplify.
FOR /F "tokens=*" %%a IN ('<...>') DO ECHO %%a
Using"tokens=*"or"delims="in yourFORloop allows processing filenames with spaces. ReplaceECHO %%awith whatever command(s) you want to run.
DIR /B
Using the/Bswitch on theDIRcommand uses bare format, including only the filenames. This is required for theFINDSTRcommand to function as we want.
^|
It is important to escape the|character when used inside the command portion of aFORloop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incompleteFORloop into something else.
FINDSTR /V /R "<...>"
The/Vswitch tellsFINDSTRto remove matches from the list and the/Rswitch turns on Regular Expression mode.
[^.]*.[^.]*.[^.]*$
[^.]*will match any string of characters that do not include the.character.
.will match the.character.
$is the "end of line" character, meaning that this regular expression must be at the end of the filename. This allows us to match files with any number of periods in the filename such astest.vhost.exe.bak.
Further Reading
- Dir - SS64.com
- Findstr - SS64.com
- For (command) - SS64.com
add a comment |
This is unfortunately not possible with only the DIR command, however it can be combined with the FINDSTR command.
I'm focusing on the more general question, rather than the specific question regarding .exe files, but you can easily modify this to narrow it down.
The FINDSTR command supports regular expression searches on the output which allows us to filter out files with more than one period in the filename.
DIR /B | FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"
I would suggest wrapping into a FOR loop as follows to do something with the returned file list:
FOR /F "tokens=*" %%a IN ('DIR /B ^| FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"') DO ECHO %%a
Breakdown
In this explanation, <...> is a placeholder for things that will be explained later. It's only there to simplify.
FOR /F "tokens=*" %%a IN ('<...>') DO ECHO %%a
Using"tokens=*"or"delims="in yourFORloop allows processing filenames with spaces. ReplaceECHO %%awith whatever command(s) you want to run.
DIR /B
Using the/Bswitch on theDIRcommand uses bare format, including only the filenames. This is required for theFINDSTRcommand to function as we want.
^|
It is important to escape the|character when used inside the command portion of aFORloop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incompleteFORloop into something else.
FINDSTR /V /R "<...>"
The/Vswitch tellsFINDSTRto remove matches from the list and the/Rswitch turns on Regular Expression mode.
[^.]*.[^.]*.[^.]*$
[^.]*will match any string of characters that do not include the.character.
.will match the.character.
$is the "end of line" character, meaning that this regular expression must be at the end of the filename. This allows us to match files with any number of periods in the filename such astest.vhost.exe.bak.
Further Reading
- Dir - SS64.com
- Findstr - SS64.com
- For (command) - SS64.com
add a comment |
This is unfortunately not possible with only the DIR command, however it can be combined with the FINDSTR command.
I'm focusing on the more general question, rather than the specific question regarding .exe files, but you can easily modify this to narrow it down.
The FINDSTR command supports regular expression searches on the output which allows us to filter out files with more than one period in the filename.
DIR /B | FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"
I would suggest wrapping into a FOR loop as follows to do something with the returned file list:
FOR /F "tokens=*" %%a IN ('DIR /B ^| FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"') DO ECHO %%a
Breakdown
In this explanation, <...> is a placeholder for things that will be explained later. It's only there to simplify.
FOR /F "tokens=*" %%a IN ('<...>') DO ECHO %%a
Using"tokens=*"or"delims="in yourFORloop allows processing filenames with spaces. ReplaceECHO %%awith whatever command(s) you want to run.
DIR /B
Using the/Bswitch on theDIRcommand uses bare format, including only the filenames. This is required for theFINDSTRcommand to function as we want.
^|
It is important to escape the|character when used inside the command portion of aFORloop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incompleteFORloop into something else.
FINDSTR /V /R "<...>"
The/Vswitch tellsFINDSTRto remove matches from the list and the/Rswitch turns on Regular Expression mode.
[^.]*.[^.]*.[^.]*$
[^.]*will match any string of characters that do not include the.character.
.will match the.character.
$is the "end of line" character, meaning that this regular expression must be at the end of the filename. This allows us to match files with any number of periods in the filename such astest.vhost.exe.bak.
Further Reading
- Dir - SS64.com
- Findstr - SS64.com
- For (command) - SS64.com
This is unfortunately not possible with only the DIR command, however it can be combined with the FINDSTR command.
I'm focusing on the more general question, rather than the specific question regarding .exe files, but you can easily modify this to narrow it down.
The FINDSTR command supports regular expression searches on the output which allows us to filter out files with more than one period in the filename.
DIR /B | FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"
I would suggest wrapping into a FOR loop as follows to do something with the returned file list:
FOR /F "tokens=*" %%a IN ('DIR /B ^| FINDSTR /V /R "[^.]*.[^.]*.[^.]*$"') DO ECHO %%a
Breakdown
In this explanation, <...> is a placeholder for things that will be explained later. It's only there to simplify.
FOR /F "tokens=*" %%a IN ('<...>') DO ECHO %%a
Using"tokens=*"or"delims="in yourFORloop allows processing filenames with spaces. ReplaceECHO %%awith whatever command(s) you want to run.
DIR /B
Using the/Bswitch on theDIRcommand uses bare format, including only the filenames. This is required for theFINDSTRcommand to function as we want.
^|
It is important to escape the|character when used inside the command portion of aFORloop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incompleteFORloop into something else.
FINDSTR /V /R "<...>"
The/Vswitch tellsFINDSTRto remove matches from the list and the/Rswitch turns on Regular Expression mode.
[^.]*.[^.]*.[^.]*$
[^.]*will match any string of characters that do not include the.character.
.will match the.character.
$is the "end of line" character, meaning that this regular expression must be at the end of the filename. This allows us to match files with any number of periods in the filename such astest.vhost.exe.bak.
Further Reading
- Dir - SS64.com
- Findstr - SS64.com
- For (command) - SS64.com
answered yesterday
WorthwelleWorthwelle
2,79531325
2,79531325
add a comment |
add a comment |
this should work:
dir *.exe /b | findstr /i ".*[^.]*.*.exe$"
in words: find a string in .exe files that does not contain a dot other than the one in .exe
2
Consider adding a note explaining why this might work if you want to make it even more helpful.
– Pimp Juice IT
yesterday
3
The two.*in the pattern will allow any number of literal dots, and the class[^*.]without a quantifier is pretty useless.
– LotPings
yesterday
add a comment |
this should work:
dir *.exe /b | findstr /i ".*[^.]*.*.exe$"
in words: find a string in .exe files that does not contain a dot other than the one in .exe
2
Consider adding a note explaining why this might work if you want to make it even more helpful.
– Pimp Juice IT
yesterday
3
The two.*in the pattern will allow any number of literal dots, and the class[^*.]without a quantifier is pretty useless.
– LotPings
yesterday
add a comment |
this should work:
dir *.exe /b | findstr /i ".*[^.]*.*.exe$"
in words: find a string in .exe files that does not contain a dot other than the one in .exe
this should work:
dir *.exe /b | findstr /i ".*[^.]*.*.exe$"
in words: find a string in .exe files that does not contain a dot other than the one in .exe
edited 15 hours ago
answered yesterday
DDSDDS
482311
482311
2
Consider adding a note explaining why this might work if you want to make it even more helpful.
– Pimp Juice IT
yesterday
3
The two.*in the pattern will allow any number of literal dots, and the class[^*.]without a quantifier is pretty useless.
– LotPings
yesterday
add a comment |
2
Consider adding a note explaining why this might work if you want to make it even more helpful.
– Pimp Juice IT
yesterday
3
The two.*in the pattern will allow any number of literal dots, and the class[^*.]without a quantifier is pretty useless.
– LotPings
yesterday
2
2
Consider adding a note explaining why this might work if you want to make it even more helpful.
– Pimp Juice IT
yesterday
Consider adding a note explaining why this might work if you want to make it even more helpful.
– Pimp Juice IT
yesterday
3
3
The two
.* in the pattern will allow any number of literal dots, and the class [^*.] without a quantifier is pretty useless.– LotPings
yesterday
The two
.* in the pattern will allow any number of literal dots, and the class [^*.] without a quantifier is pretty useless.– LotPings
yesterday
add a comment |
610163 is a new contributor. Be nice, and check out our Code of Conduct.
610163 is a new contributor. Be nice, and check out our Code of Conduct.
610163 is a new contributor. Be nice, and check out our Code of Conduct.
610163 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1411501%2fdir-command-that-ignores-files-with-multiple-extensions%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