Filenames matching regex but in folder with wildcard





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















This is a follow up question of: PowerShell concatenate output of Get-ChildItem



This code works fine:



Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*.vue" -Recurse -File |
Where-Object { $_.BaseName -match '^[0-9]+$' } |
ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' } |
Out-File D:wim.txt


But I would need to restrict the search folder to only certain folders, basically, this filter: D:WimTM1TI processes\*}vues (so all subfolders ending in }vues).



If I add that wildcard condition I get no result. Without the restriction, I get the correct result. Is this possible please?



without filter



with filter



The idea is to get rid of the 3rd line in the first output (which was a copy/paste by me) and also to minimize the number of folders to look at.










share|improve this question































    1















    This is a follow up question of: PowerShell concatenate output of Get-ChildItem



    This code works fine:



    Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*.vue" -Recurse -File |
    Where-Object { $_.BaseName -match '^[0-9]+$' } |
    ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' } |
    Out-File D:wim.txt


    But I would need to restrict the search folder to only certain folders, basically, this filter: D:WimTM1TI processes\*}vues (so all subfolders ending in }vues).



    If I add that wildcard condition I get no result. Without the restriction, I get the correct result. Is this possible please?



    without filter



    with filter



    The idea is to get rid of the 3rd line in the first output (which was a copy/paste by me) and also to minimize the number of folders to look at.










    share|improve this question



























      1












      1








      1








      This is a follow up question of: PowerShell concatenate output of Get-ChildItem



      This code works fine:



      Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*.vue" -Recurse -File |
      Where-Object { $_.BaseName -match '^[0-9]+$' } |
      ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' } |
      Out-File D:wim.txt


      But I would need to restrict the search folder to only certain folders, basically, this filter: D:WimTM1TI processes\*}vues (so all subfolders ending in }vues).



      If I add that wildcard condition I get no result. Without the restriction, I get the correct result. Is this possible please?



      without filter



      with filter



      The idea is to get rid of the 3rd line in the first output (which was a copy/paste by me) and also to minimize the number of folders to look at.










      share|improve this question
















      This is a follow up question of: PowerShell concatenate output of Get-ChildItem



      This code works fine:



      Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*.vue" -Recurse -File |
      Where-Object { $_.BaseName -match '^[0-9]+$' } |
      ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' } |
      Out-File D:wim.txt


      But I would need to restrict the search folder to only certain folders, basically, this filter: D:WimTM1TI processes\*}vues (so all subfolders ending in }vues).



      If I add that wildcard condition I get no result. Without the restriction, I get the correct result. Is this possible please?



      without filter



      with filter



      The idea is to get rid of the 3rd line in the first output (which was a copy/paste by me) and also to minimize the number of folders to look at.







      powershell string-formatting






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 21:30









      Ansgar Wiechers

      146k13135193




      146k13135193










      asked Nov 26 '18 at 20:25









      W. GielisW. Gielis

      174




      174
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You can nest two Get-ChildItem calls:




          • An outer Get-ChildItem -Directory -Recurse call to filter directories of interest first,


          • an inner Get-ChildItem -File call that, for each directory found, examines and processes the files of interest.



          Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*}vues" -Recurse -Directory |
          ForEach-Object {
          Get-ChildItem -LiteralPath $_.FullName -Filter "*.vue" -File |
          Where-Object { $_.BaseName -match '^[0-9]+$' } |
          ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' }
          } | Out-File D:wim.txt


          Note: The assumption is that all *.vue files of interest are located directly in each *}vues folder.





          As for what you tried:



          Given that you're limiting items being enumerated to files (-File), your directory-name wildcard pattern *}vues never gets to match any directory names and, in the absence of files matching that pattern, returns nothing.



          Generally, with -Recurse it is conceptually cleaner not to append the wildcard pattern directly to the -Path argument, so as to better signal that the pattern will be matched in every directory in the subtree.



          In your case you would have noticed your attempt to filter doubly, given that you're also using the -Filter parameter.






          share|improve this answer





















          • 1





            Bingo ! Great work. And I should have spotted that one myself.

            – W. Gielis
            Nov 26 '18 at 22:02











          • @W.Gielis: Thanks; no worries; I'm glad we got there.

            – mklement0
            Nov 26 '18 at 22:26












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53488504%2ffilenames-matching-regex-but-in-folder-with-wildcard%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









          1














          You can nest two Get-ChildItem calls:




          • An outer Get-ChildItem -Directory -Recurse call to filter directories of interest first,


          • an inner Get-ChildItem -File call that, for each directory found, examines and processes the files of interest.



          Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*}vues" -Recurse -Directory |
          ForEach-Object {
          Get-ChildItem -LiteralPath $_.FullName -Filter "*.vue" -File |
          Where-Object { $_.BaseName -match '^[0-9]+$' } |
          ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' }
          } | Out-File D:wim.txt


          Note: The assumption is that all *.vue files of interest are located directly in each *}vues folder.





          As for what you tried:



          Given that you're limiting items being enumerated to files (-File), your directory-name wildcard pattern *}vues never gets to match any directory names and, in the absence of files matching that pattern, returns nothing.



          Generally, with -Recurse it is conceptually cleaner not to append the wildcard pattern directly to the -Path argument, so as to better signal that the pattern will be matched in every directory in the subtree.



          In your case you would have noticed your attempt to filter doubly, given that you're also using the -Filter parameter.






          share|improve this answer





















          • 1





            Bingo ! Great work. And I should have spotted that one myself.

            – W. Gielis
            Nov 26 '18 at 22:02











          • @W.Gielis: Thanks; no worries; I'm glad we got there.

            – mklement0
            Nov 26 '18 at 22:26
















          1














          You can nest two Get-ChildItem calls:




          • An outer Get-ChildItem -Directory -Recurse call to filter directories of interest first,


          • an inner Get-ChildItem -File call that, for each directory found, examines and processes the files of interest.



          Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*}vues" -Recurse -Directory |
          ForEach-Object {
          Get-ChildItem -LiteralPath $_.FullName -Filter "*.vue" -File |
          Where-Object { $_.BaseName -match '^[0-9]+$' } |
          ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' }
          } | Out-File D:wim.txt


          Note: The assumption is that all *.vue files of interest are located directly in each *}vues folder.





          As for what you tried:



          Given that you're limiting items being enumerated to files (-File), your directory-name wildcard pattern *}vues never gets to match any directory names and, in the absence of files matching that pattern, returns nothing.



          Generally, with -Recurse it is conceptually cleaner not to append the wildcard pattern directly to the -Path argument, so as to better signal that the pattern will be matched in every directory in the subtree.



          In your case you would have noticed your attempt to filter doubly, given that you're also using the -Filter parameter.






          share|improve this answer





















          • 1





            Bingo ! Great work. And I should have spotted that one myself.

            – W. Gielis
            Nov 26 '18 at 22:02











          • @W.Gielis: Thanks; no worries; I'm glad we got there.

            – mklement0
            Nov 26 '18 at 22:26














          1












          1








          1







          You can nest two Get-ChildItem calls:




          • An outer Get-ChildItem -Directory -Recurse call to filter directories of interest first,


          • an inner Get-ChildItem -File call that, for each directory found, examines and processes the files of interest.



          Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*}vues" -Recurse -Directory |
          ForEach-Object {
          Get-ChildItem -LiteralPath $_.FullName -Filter "*.vue" -File |
          Where-Object { $_.BaseName -match '^[0-9]+$' } |
          ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' }
          } | Out-File D:wim.txt


          Note: The assumption is that all *.vue files of interest are located directly in each *}vues folder.





          As for what you tried:



          Given that you're limiting items being enumerated to files (-File), your directory-name wildcard pattern *}vues never gets to match any directory names and, in the absence of files matching that pattern, returns nothing.



          Generally, with -Recurse it is conceptually cleaner not to append the wildcard pattern directly to the -Path argument, so as to better signal that the pattern will be matched in every directory in the subtree.



          In your case you would have noticed your attempt to filter doubly, given that you're also using the -Filter parameter.






          share|improve this answer















          You can nest two Get-ChildItem calls:




          • An outer Get-ChildItem -Directory -Recurse call to filter directories of interest first,


          • an inner Get-ChildItem -File call that, for each directory found, examines and processes the files of interest.



          Get-ChildItem -Path "D:WimTM1TI processes" -Filter "*}vues" -Recurse -Directory |
          ForEach-Object {
          Get-ChildItem -LiteralPath $_.FullName -Filter "*.vue" -File |
          Where-Object { $_.BaseName -match '^[0-9]+$' } |
          ForEach-Object { ($_.FullName -split '\')[-2,-1] -join '' }
          } | Out-File D:wim.txt


          Note: The assumption is that all *.vue files of interest are located directly in each *}vues folder.





          As for what you tried:



          Given that you're limiting items being enumerated to files (-File), your directory-name wildcard pattern *}vues never gets to match any directory names and, in the absence of files matching that pattern, returns nothing.



          Generally, with -Recurse it is conceptually cleaner not to append the wildcard pattern directly to the -Path argument, so as to better signal that the pattern will be matched in every directory in the subtree.



          In your case you would have noticed your attempt to filter doubly, given that you're also using the -Filter parameter.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 26 '18 at 21:57

























          answered Nov 26 '18 at 20:39









          mklement0mklement0

          139k23256293




          139k23256293








          • 1





            Bingo ! Great work. And I should have spotted that one myself.

            – W. Gielis
            Nov 26 '18 at 22:02











          • @W.Gielis: Thanks; no worries; I'm glad we got there.

            – mklement0
            Nov 26 '18 at 22:26














          • 1





            Bingo ! Great work. And I should have spotted that one myself.

            – W. Gielis
            Nov 26 '18 at 22:02











          • @W.Gielis: Thanks; no worries; I'm glad we got there.

            – mklement0
            Nov 26 '18 at 22:26








          1




          1





          Bingo ! Great work. And I should have spotted that one myself.

          – W. Gielis
          Nov 26 '18 at 22:02





          Bingo ! Great work. And I should have spotted that one myself.

          – W. Gielis
          Nov 26 '18 at 22:02













          @W.Gielis: Thanks; no worries; I'm glad we got there.

          – mklement0
          Nov 26 '18 at 22:26





          @W.Gielis: Thanks; no worries; I'm glad we got there.

          – mklement0
          Nov 26 '18 at 22:26




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53488504%2ffilenames-matching-regex-but-in-folder-with-wildcard%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

          To store a contact into the json file from server.js file using a class in NodeJS

          Redirect URL with Chrome Remote Debugging Android Devices

          Dieringhausen