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













3















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.










share|improve this question







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.

























    3















    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.










    share|improve this question







    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.























      3












      3








      3








      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.










      share|improve this question







      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






      share|improve this question







      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.











      share|improve this question







      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.









      share|improve this question




      share|improve this question






      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.






















          2 Answers
          2






          active

          oldest

          votes


















          3














          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 your FOR loop allows processing filenames with spaces. Replace ECHO %%a with whatever command(s) you want to run.


          • DIR /B

            Using the /B switch on the DIR command uses bare format, including only the filenames. This is required for the FINDSTR command to function as we want.


          • ^|

            It is important to escape the | character when used inside the command portion of a FOR loop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incomplete FOR loop into something else.


          • FINDSTR /V /R "<...>"

            The /V switch tells FINDSTR to remove matches from the list and the /R switch 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 as test.vhost.exe.bak.




          Further Reading




          • Dir - SS64.com

          • Findstr - SS64.com

          • For (command) - SS64.com






          share|improve this answer































            0














            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






            share|improve this answer





















            • 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











            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.










            draft saved

            draft discarded


















            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









            3














            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 your FOR loop allows processing filenames with spaces. Replace ECHO %%a with whatever command(s) you want to run.


            • DIR /B

              Using the /B switch on the DIR command uses bare format, including only the filenames. This is required for the FINDSTR command to function as we want.


            • ^|

              It is important to escape the | character when used inside the command portion of a FOR loop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incomplete FOR loop into something else.


            • FINDSTR /V /R "<...>"

              The /V switch tells FINDSTR to remove matches from the list and the /R switch 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 as test.vhost.exe.bak.




            Further Reading




            • Dir - SS64.com

            • Findstr - SS64.com

            • For (command) - SS64.com






            share|improve this answer




























              3














              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 your FOR loop allows processing filenames with spaces. Replace ECHO %%a with whatever command(s) you want to run.


              • DIR /B

                Using the /B switch on the DIR command uses bare format, including only the filenames. This is required for the FINDSTR command to function as we want.


              • ^|

                It is important to escape the | character when used inside the command portion of a FOR loop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incomplete FOR loop into something else.


              • FINDSTR /V /R "<...>"

                The /V switch tells FINDSTR to remove matches from the list and the /R switch 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 as test.vhost.exe.bak.




              Further Reading




              • Dir - SS64.com

              • Findstr - SS64.com

              • For (command) - SS64.com






              share|improve this answer


























                3












                3








                3







                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 your FOR loop allows processing filenames with spaces. Replace ECHO %%a with whatever command(s) you want to run.


                • DIR /B

                  Using the /B switch on the DIR command uses bare format, including only the filenames. This is required for the FINDSTR command to function as we want.


                • ^|

                  It is important to escape the | character when used inside the command portion of a FOR loop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incomplete FOR loop into something else.


                • FINDSTR /V /R "<...>"

                  The /V switch tells FINDSTR to remove matches from the list and the /R switch 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 as test.vhost.exe.bak.




                Further Reading




                • Dir - SS64.com

                • Findstr - SS64.com

                • For (command) - SS64.com






                share|improve this answer













                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 your FOR loop allows processing filenames with spaces. Replace ECHO %%a with whatever command(s) you want to run.


                • DIR /B

                  Using the /B switch on the DIR command uses bare format, including only the filenames. This is required for the FINDSTR command to function as we want.


                • ^|

                  It is important to escape the | character when used inside the command portion of a FOR loop. Otherwise you'll get a syntax error because it thinks you're trying to pipe the incomplete FOR loop into something else.


                • FINDSTR /V /R "<...>"

                  The /V switch tells FINDSTR to remove matches from the list and the /R switch 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 as test.vhost.exe.bak.




                Further Reading




                • Dir - SS64.com

                • Findstr - SS64.com

                • For (command) - SS64.com







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                WorthwelleWorthwelle

                2,79531325




                2,79531325

























                    0














                    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






                    share|improve this answer





















                    • 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
















                    0














                    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






                    share|improve this answer





















                    • 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














                    0












                    0








                    0







                    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






                    share|improve this answer















                    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







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    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














                    • 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










                    610163 is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Cannot install PyQt5 The Next CEO of Stack OverflowCannot install tcpreplay 3.4.4cannot...

                    Kapp-Putsch Acontecimentos | Outros artigos | Menu de navegação

                    Why did early computer designers eschew integers? The Next CEO of Stack OverflowWhat register...