Remove multiple copies of folder that starts with same name using batch-file Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow can I pass arguments to a batch file?Batch file to delete files older than N daysSplit long commands in multiple lines through Windows batch fileWindows batch files: .bat vs .cmd?How to run multiple .BAT files within a .BAT fileHow to verify if a file exists in a batch file?What is the current directory in a batch file?copying all contents of folder to another folder using batch file?Batch file. Delete all files and folders in a directoryHow do I find all files containing specific text on Linux?

What's the difference between (size_t)-1 and ~0?

Determine whether f is a function, an injection, a surjection

How can players take actions together that are impossible otherwise?

Was credit for the black hole image misattributed?

I'm having difficulty getting my players to do stuff in a sandbox campaign

When is phishing education going too far?

Antler Helmet: Can it work?

Estimate capacitor parameters

What can I do if my MacBook isn’t charging but already ran out?

How to say that you spent the night with someone, you were only sleeping and nothing else?

Simulating Exploding Dice

Geometric mean and geometric standard deviation

Is there a service that would inform me whenever a new direct route is scheduled from a given airport?

If I can make up priors, why can't I make up posteriors?

How to market an anarchic city as a tourism spot to people living in civilized areas?

Are my PIs rude or am I just being too sensitive?

Cold is to Refrigerator as warm is to?

3 doors, three guards, one stone

New Order #5: where Fibonacci and Beatty meet at Wythoff

Complexity of many constant time steps with occasional logarithmic steps

Mortgage adviser recommends a longer term than necessary combined with overpayments

What do you call a plan that's an alternative plan in case your initial plan fails?

Why is "Captain Marvel" translated as male in Portugal?

Area of a 2D convex hull



Remove multiple copies of folder that starts with same name using batch-file



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow can I pass arguments to a batch file?Batch file to delete files older than N daysSplit long commands in multiple lines through Windows batch fileWindows batch files: .bat vs .cmd?How to run multiple .BAT files within a .BAT fileHow to verify if a file exists in a batch file?What is the current directory in a batch file?copying all contents of folder to another folder using batch file?Batch file. Delete all files and folders in a directoryHow do I find all files containing specific text on Linux?



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








0















My DESKTOP contain copies of 'CEEMEA EMEA' folder i.e.



EMEA CEEMEA



EMEA CEEMEA - Copy



EMEA CEEMEA - Copy (2)



EMEA CEEMEA - Copy (3)



and so on



I want to delete all folders that starts with EMEA CEEMEA as file name using CMD or batch-file.



rd /s /q "%CD%NEW FOLDER*"


but above command not doing anything. how does it work?










share|improve this question






























    0















    My DESKTOP contain copies of 'CEEMEA EMEA' folder i.e.



    EMEA CEEMEA



    EMEA CEEMEA - Copy



    EMEA CEEMEA - Copy (2)



    EMEA CEEMEA - Copy (3)



    and so on



    I want to delete all folders that starts with EMEA CEEMEA as file name using CMD or batch-file.



    rd /s /q "%CD%NEW FOLDER*"


    but above command not doing anything. how does it work?










    share|improve this question


























      0












      0








      0








      My DESKTOP contain copies of 'CEEMEA EMEA' folder i.e.



      EMEA CEEMEA



      EMEA CEEMEA - Copy



      EMEA CEEMEA - Copy (2)



      EMEA CEEMEA - Copy (3)



      and so on



      I want to delete all folders that starts with EMEA CEEMEA as file name using CMD or batch-file.



      rd /s /q "%CD%NEW FOLDER*"


      but above command not doing anything. how does it work?










      share|improve this question
















      My DESKTOP contain copies of 'CEEMEA EMEA' folder i.e.



      EMEA CEEMEA



      EMEA CEEMEA - Copy



      EMEA CEEMEA - Copy (2)



      EMEA CEEMEA - Copy (3)



      and so on



      I want to delete all folders that starts with EMEA CEEMEA as file name using CMD or batch-file.



      rd /s /q "%CD%NEW FOLDER*"


      but above command not doing anything. how does it work?







      batch-file cmd directory






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 25 at 7:58







      Ibn e Ashiq

















      asked Mar 22 at 7:43









      Ibn e AshiqIbn e Ashiq

      3221620




      3221620






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You can do this using a For loop with its /D option:



          For /D %A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%A"


          As you've updated your question to include batch-file, you'd change the command to this from one:



          For /D %%A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%%A"





          share|improve this answer




















          • 1





            I'd prefer that you first take a look at the usage information for both of the commands used. Open a Command Prompt window and enter For /?, and read its content, paying additional note to its /D option. Next repeat the process using RD /?. After you've read them, if you still have any questions pertaining to this particular line of code, post back, and we'll see if we can help explain. Essentially it looks for directories, matching the wilcarded fileset in parentheses, and outputs each match, one at a time , as the metavariable %A, which is subsequently used in the Do command, RD.

            – Compo
            Mar 23 at 16:52











          • actually I need to use this For /D %A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%A" in .bat file and it does nothing.. is there anything I could change ??

            – Ibn e Ashiq
            Mar 25 at 6:09







          • 1





            It all depends upon where your batch file is located or what your current working directory is at the time the line is ran. You stated My DESKTOP, so I provided, the location for that. One thing is for sure, you do not need the %CD% part, because any location which is not a fully qualified path will be taken as relative to the current directory.

            – Compo
            Mar 25 at 8:20












          • you are right about Desktop. Problem with my command was I did not use %% percentage, now For /D %%A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%%A" is working fine.

            – Ibn e Ashiq
            Mar 25 at 8:26











          • I updated my answer, when I noticed that you'd modified your question to include the batch file requirement.

            – Compo
            Mar 25 at 8:28











          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%2f55294961%2fremove-multiple-copies-of-folder-that-starts-with-same-name-using-batch-file%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 do this using a For loop with its /D option:



          For /D %A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%A"


          As you've updated your question to include batch-file, you'd change the command to this from one:



          For /D %%A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%%A"





          share|improve this answer




















          • 1





            I'd prefer that you first take a look at the usage information for both of the commands used. Open a Command Prompt window and enter For /?, and read its content, paying additional note to its /D option. Next repeat the process using RD /?. After you've read them, if you still have any questions pertaining to this particular line of code, post back, and we'll see if we can help explain. Essentially it looks for directories, matching the wilcarded fileset in parentheses, and outputs each match, one at a time , as the metavariable %A, which is subsequently used in the Do command, RD.

            – Compo
            Mar 23 at 16:52











          • actually I need to use this For /D %A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%A" in .bat file and it does nothing.. is there anything I could change ??

            – Ibn e Ashiq
            Mar 25 at 6:09







          • 1





            It all depends upon where your batch file is located or what your current working directory is at the time the line is ran. You stated My DESKTOP, so I provided, the location for that. One thing is for sure, you do not need the %CD% part, because any location which is not a fully qualified path will be taken as relative to the current directory.

            – Compo
            Mar 25 at 8:20












          • you are right about Desktop. Problem with my command was I did not use %% percentage, now For /D %%A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%%A" is working fine.

            – Ibn e Ashiq
            Mar 25 at 8:26











          • I updated my answer, when I noticed that you'd modified your question to include the batch file requirement.

            – Compo
            Mar 25 at 8:28















          1














          You can do this using a For loop with its /D option:



          For /D %A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%A"


          As you've updated your question to include batch-file, you'd change the command to this from one:



          For /D %%A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%%A"





          share|improve this answer




















          • 1





            I'd prefer that you first take a look at the usage information for both of the commands used. Open a Command Prompt window and enter For /?, and read its content, paying additional note to its /D option. Next repeat the process using RD /?. After you've read them, if you still have any questions pertaining to this particular line of code, post back, and we'll see if we can help explain. Essentially it looks for directories, matching the wilcarded fileset in parentheses, and outputs each match, one at a time , as the metavariable %A, which is subsequently used in the Do command, RD.

            – Compo
            Mar 23 at 16:52











          • actually I need to use this For /D %A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%A" in .bat file and it does nothing.. is there anything I could change ??

            – Ibn e Ashiq
            Mar 25 at 6:09







          • 1





            It all depends upon where your batch file is located or what your current working directory is at the time the line is ran. You stated My DESKTOP, so I provided, the location for that. One thing is for sure, you do not need the %CD% part, because any location which is not a fully qualified path will be taken as relative to the current directory.

            – Compo
            Mar 25 at 8:20












          • you are right about Desktop. Problem with my command was I did not use %% percentage, now For /D %%A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%%A" is working fine.

            – Ibn e Ashiq
            Mar 25 at 8:26











          • I updated my answer, when I noticed that you'd modified your question to include the batch file requirement.

            – Compo
            Mar 25 at 8:28













          1












          1








          1







          You can do this using a For loop with its /D option:



          For /D %A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%A"


          As you've updated your question to include batch-file, you'd change the command to this from one:



          For /D %%A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%%A"





          share|improve this answer















          You can do this using a For loop with its /D option:



          For /D %A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%A"


          As you've updated your question to include batch-file, you'd change the command to this from one:



          For /D %%A In ("%UserProfile%DesktopEMEA CEEMEA*")Do @RD/S/Q "%%A"






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 25 at 8:26

























          answered Mar 22 at 19:32









          CompoCompo

          17.2k31027




          17.2k31027







          • 1





            I'd prefer that you first take a look at the usage information for both of the commands used. Open a Command Prompt window and enter For /?, and read its content, paying additional note to its /D option. Next repeat the process using RD /?. After you've read them, if you still have any questions pertaining to this particular line of code, post back, and we'll see if we can help explain. Essentially it looks for directories, matching the wilcarded fileset in parentheses, and outputs each match, one at a time , as the metavariable %A, which is subsequently used in the Do command, RD.

            – Compo
            Mar 23 at 16:52











          • actually I need to use this For /D %A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%A" in .bat file and it does nothing.. is there anything I could change ??

            – Ibn e Ashiq
            Mar 25 at 6:09







          • 1





            It all depends upon where your batch file is located or what your current working directory is at the time the line is ran. You stated My DESKTOP, so I provided, the location for that. One thing is for sure, you do not need the %CD% part, because any location which is not a fully qualified path will be taken as relative to the current directory.

            – Compo
            Mar 25 at 8:20












          • you are right about Desktop. Problem with my command was I did not use %% percentage, now For /D %%A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%%A" is working fine.

            – Ibn e Ashiq
            Mar 25 at 8:26











          • I updated my answer, when I noticed that you'd modified your question to include the batch file requirement.

            – Compo
            Mar 25 at 8:28












          • 1





            I'd prefer that you first take a look at the usage information for both of the commands used. Open a Command Prompt window and enter For /?, and read its content, paying additional note to its /D option. Next repeat the process using RD /?. After you've read them, if you still have any questions pertaining to this particular line of code, post back, and we'll see if we can help explain. Essentially it looks for directories, matching the wilcarded fileset in parentheses, and outputs each match, one at a time , as the metavariable %A, which is subsequently used in the Do command, RD.

            – Compo
            Mar 23 at 16:52











          • actually I need to use this For /D %A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%A" in .bat file and it does nothing.. is there anything I could change ??

            – Ibn e Ashiq
            Mar 25 at 6:09







          • 1





            It all depends upon where your batch file is located or what your current working directory is at the time the line is ran. You stated My DESKTOP, so I provided, the location for that. One thing is for sure, you do not need the %CD% part, because any location which is not a fully qualified path will be taken as relative to the current directory.

            – Compo
            Mar 25 at 8:20












          • you are right about Desktop. Problem with my command was I did not use %% percentage, now For /D %%A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%%A" is working fine.

            – Ibn e Ashiq
            Mar 25 at 8:26











          • I updated my answer, when I noticed that you'd modified your question to include the batch file requirement.

            – Compo
            Mar 25 at 8:28







          1




          1





          I'd prefer that you first take a look at the usage information for both of the commands used. Open a Command Prompt window and enter For /?, and read its content, paying additional note to its /D option. Next repeat the process using RD /?. After you've read them, if you still have any questions pertaining to this particular line of code, post back, and we'll see if we can help explain. Essentially it looks for directories, matching the wilcarded fileset in parentheses, and outputs each match, one at a time , as the metavariable %A, which is subsequently used in the Do command, RD.

          – Compo
          Mar 23 at 16:52





          I'd prefer that you first take a look at the usage information for both of the commands used. Open a Command Prompt window and enter For /?, and read its content, paying additional note to its /D option. Next repeat the process using RD /?. After you've read them, if you still have any questions pertaining to this particular line of code, post back, and we'll see if we can help explain. Essentially it looks for directories, matching the wilcarded fileset in parentheses, and outputs each match, one at a time , as the metavariable %A, which is subsequently used in the Do command, RD.

          – Compo
          Mar 23 at 16:52













          actually I need to use this For /D %A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%A" in .bat file and it does nothing.. is there anything I could change ??

          – Ibn e Ashiq
          Mar 25 at 6:09






          actually I need to use this For /D %A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%A" in .bat file and it does nothing.. is there anything I could change ??

          – Ibn e Ashiq
          Mar 25 at 6:09





          1




          1





          It all depends upon where your batch file is located or what your current working directory is at the time the line is ran. You stated My DESKTOP, so I provided, the location for that. One thing is for sure, you do not need the %CD% part, because any location which is not a fully qualified path will be taken as relative to the current directory.

          – Compo
          Mar 25 at 8:20






          It all depends upon where your batch file is located or what your current working directory is at the time the line is ran. You stated My DESKTOP, so I provided, the location for that. One thing is for sure, you do not need the %CD% part, because any location which is not a fully qualified path will be taken as relative to the current directory.

          – Compo
          Mar 25 at 8:20














          you are right about Desktop. Problem with my command was I did not use %% percentage, now For /D %%A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%%A" is working fine.

          – Ibn e Ashiq
          Mar 25 at 8:26





          you are right about Desktop. Problem with my command was I did not use %% percentage, now For /D %%A In ("%CD%EMEA CEEMEA*")Do @RD/S/Q "%%A" is working fine.

          – Ibn e Ashiq
          Mar 25 at 8:26













          I updated my answer, when I noticed that you'd modified your question to include the batch file requirement.

          – Compo
          Mar 25 at 8:28





          I updated my answer, when I noticed that you'd modified your question to include the batch file requirement.

          – Compo
          Mar 25 at 8:28



















          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%2f55294961%2fremove-multiple-copies-of-folder-that-starts-with-same-name-using-batch-file%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현