Windows bulk rename middle filename via CLI?












12














Original Files



File 15 - Example.txt
File 2 - Example.txt
File 22 - Example.txt
File 3 - Example.txt
File 4 - Example.txt
File 5 - Example.txt


Desired Output



File 15 - Example.txt
File 02 - Example.txt
File 22 - Example.txt
File 03 - Example.txt
File 04 - Example.txt
File 05 - Example.txt


Single file can be renamed easily with ren.



ren "File 2 - Example.txt" "File 02 - Example.txt"


Would it be possible to bulk rename it with Windows ren or rename tool?










share|improve this question




















  • 1




    Nice Free utility to make this type of task easy....bulkrenameutility.co.uk/Main_Intro.php
    – Moab
    yesterday










  • I agree. I can name plenty of GUI based solutions for this, and wonder why the insistence on CLI
    – Mawg
    20 hours ago










  • @Mawg, can u do scripting with those GUI tools?
    – Sabrina
    20 hours ago










  • I could - using AutoIt - but would probably recommend against it :-) I just wondered if there was a hard requirement for CLI, and now it seems like there is. Thanks for clarifying
    – Mawg
    20 hours ago
















12














Original Files



File 15 - Example.txt
File 2 - Example.txt
File 22 - Example.txt
File 3 - Example.txt
File 4 - Example.txt
File 5 - Example.txt


Desired Output



File 15 - Example.txt
File 02 - Example.txt
File 22 - Example.txt
File 03 - Example.txt
File 04 - Example.txt
File 05 - Example.txt


Single file can be renamed easily with ren.



ren "File 2 - Example.txt" "File 02 - Example.txt"


Would it be possible to bulk rename it with Windows ren or rename tool?










share|improve this question




















  • 1




    Nice Free utility to make this type of task easy....bulkrenameutility.co.uk/Main_Intro.php
    – Moab
    yesterday










  • I agree. I can name plenty of GUI based solutions for this, and wonder why the insistence on CLI
    – Mawg
    20 hours ago










  • @Mawg, can u do scripting with those GUI tools?
    – Sabrina
    20 hours ago










  • I could - using AutoIt - but would probably recommend against it :-) I just wondered if there was a hard requirement for CLI, and now it seems like there is. Thanks for clarifying
    – Mawg
    20 hours ago














12












12








12


3





Original Files



File 15 - Example.txt
File 2 - Example.txt
File 22 - Example.txt
File 3 - Example.txt
File 4 - Example.txt
File 5 - Example.txt


Desired Output



File 15 - Example.txt
File 02 - Example.txt
File 22 - Example.txt
File 03 - Example.txt
File 04 - Example.txt
File 05 - Example.txt


Single file can be renamed easily with ren.



ren "File 2 - Example.txt" "File 02 - Example.txt"


Would it be possible to bulk rename it with Windows ren or rename tool?










share|improve this question















Original Files



File 15 - Example.txt
File 2 - Example.txt
File 22 - Example.txt
File 3 - Example.txt
File 4 - Example.txt
File 5 - Example.txt


Desired Output



File 15 - Example.txt
File 02 - Example.txt
File 22 - Example.txt
File 03 - Example.txt
File 04 - Example.txt
File 05 - Example.txt


Single file can be renamed easily with ren.



ren "File 2 - Example.txt" "File 02 - Example.txt"


Would it be possible to bulk rename it with Windows ren or rename tool?







windows command-line batch-file rename






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









LotPings

4,6461722




4,6461722










asked yesterday









Sabrina

3791314




3791314








  • 1




    Nice Free utility to make this type of task easy....bulkrenameutility.co.uk/Main_Intro.php
    – Moab
    yesterday










  • I agree. I can name plenty of GUI based solutions for this, and wonder why the insistence on CLI
    – Mawg
    20 hours ago










  • @Mawg, can u do scripting with those GUI tools?
    – Sabrina
    20 hours ago










  • I could - using AutoIt - but would probably recommend against it :-) I just wondered if there was a hard requirement for CLI, and now it seems like there is. Thanks for clarifying
    – Mawg
    20 hours ago














  • 1




    Nice Free utility to make this type of task easy....bulkrenameutility.co.uk/Main_Intro.php
    – Moab
    yesterday










  • I agree. I can name plenty of GUI based solutions for this, and wonder why the insistence on CLI
    – Mawg
    20 hours ago










  • @Mawg, can u do scripting with those GUI tools?
    – Sabrina
    20 hours ago










  • I could - using AutoIt - but would probably recommend against it :-) I just wondered if there was a hard requirement for CLI, and now it seems like there is. Thanks for clarifying
    – Mawg
    20 hours ago








1




1




Nice Free utility to make this type of task easy....bulkrenameutility.co.uk/Main_Intro.php
– Moab
yesterday




Nice Free utility to make this type of task easy....bulkrenameutility.co.uk/Main_Intro.php
– Moab
yesterday












I agree. I can name plenty of GUI based solutions for this, and wonder why the insistence on CLI
– Mawg
20 hours ago




I agree. I can name plenty of GUI based solutions for this, and wonder why the insistence on CLI
– Mawg
20 hours ago












@Mawg, can u do scripting with those GUI tools?
– Sabrina
20 hours ago




@Mawg, can u do scripting with those GUI tools?
– Sabrina
20 hours ago












I could - using AutoIt - but would probably recommend against it :-) I just wondered if there was a hard requirement for CLI, and now it seems like there is. Thanks for clarifying
– Mawg
20 hours ago




I could - using AutoIt - but would probably recommend against it :-) I just wondered if there was a hard requirement for CLI, and now it seems like there is. Thanks for clarifying
– Mawg
20 hours ago










4 Answers
4






active

oldest

votes


















13














Would it be possible to bulk rename it with Windows ren or rename tool?



Yes, but it requires a batch file.



test.cmd:



@echo off
setlocal EnableDelayedExpansion
for /f "tokens=1,2,3,4" %%i in ('dir /b *Example.txt') do (
rem pad 2nd token with leading zero
set _num=0%%j
set _num=!_num:~-2!
ren "%%i %%j %%k %%l" "%%i !_num! %%k %%l"
)
endlocal


example:



> dir *Example.txt
Volume in drive F is Expansion
Volume Serial Number is 3656-BB63

Directory of F:testtest

03/01/2019 11:30 0 File 15 - Example.txt
03/01/2019 11:30 0 File 2 - Example.txt
03/01/2019 11:30 0 File 22 - Example.txt
03/01/2019 11:30 0 File 3 - Example.txt
03/01/2019 11:30 0 File 4 - Example.txt
03/01/2019 11:30 0 File 5 - Example.txt
6 File(s) 0 bytes
0 Dir(s) 1,075,134,230,528 bytes free

> ..test

> dir
Volume in drive F is Expansion
Volume Serial Number is 3656-BB63

Directory of F:testtest

03/01/2019 11:54 <DIR> .
03/01/2019 11:54 <DIR> ..
03/01/2019 11:30 0 File 02 - Example.txt
03/01/2019 11:30 0 File 03 - Example.txt
03/01/2019 11:30 0 File 04 - Example.txt
03/01/2019 11:30 0 File 05 - Example.txt
03/01/2019 11:30 0 File 15 - Example.txt
03/01/2019 11:30 0 File 22 - Example.txt
6 File(s) 0 bytes
2 Dir(s) 1,075,134,230,528 bytes free




Further Reading




  • An A-Z Index of the Windows CMD command line | SS64.com

  • Windows CMD Commands (categorized) - Windows CMD - SS64.com

  • Dir - list files and folders - Windows CMD - SS64.com

  • EnableDelayedExpansion - Windows CMD - SS64.com

  • For - Loop through command output - Windows CMD - SS64.com

  • variable substring - Windows CMD - SS64.com






share|improve this answer





























    17














    This PowerShell one liner will expand all numbers in the file name to two places .PadLeft(2,'0'):

    (and leave numbers with more places untouched)



    Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}


    to be on topic, wrapped in a cmd line/batch file:



    Powershell -Nop -C "Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}"


    To be on the safe side before executing the commands, append either





    • -Confirm which asks before doing a rename


    • -WhatIfwhich lists all renames it would execute without the parameter


    just in front of the last "






    share|improve this answer































      3














      Edit: I've just noticed this question is specifically about renaming from the command line, so it does not answer the question directly... I'll keep it for now, hoping it will be useful for others.





      The Total Commander file manager has an excellent bulk rename tool. It includes many features, including rename preview, different rename masks, regular expressions, renaming files in entire folder hierarcy, and much more. At the same time, it is quite easy to use.



      Here's a screenshot for demonstrating its usage:



      Total Commander Multi Rename Example



      Step by step:





      1. Download and run Total Commander.

      2. Nativate to the folder with the files to rename.

      3. Mark the files to rename:


        • Option 1 - Ctrl + A for marking all files in the folder.

        • Option 2 - Mark files one by one, using the Space key or mouse right click.

        • Option 3 - Open "Find Files" (Alt + F7), type *.txt in the "Search for" box, click "Start Search", press "Feed to listbox", then mark the files with Ctrl + A.
          Use this technique if you want to rename files also in inner folders.



      4. Press Ctrl + M to open the Multi-Rename tool.

      5. Set the desired values in "Search for" and "Replace with" boxes. If using a regular expression, check the RegEx box.

      6. Hit "Start!".






      share|improve this answer































        -2














        ren *.bat *.txt will work to rename extensions on all matching files retaining the other portion of the name. Could you not abuse this to run a sequence of ren commands?





        • ren "File *" "File 0*"

        • ren "File 00*" "File 0*"

        • (deal with dangling remainders like File 022 - Example.txt






        share|improve this answer





















        • This is NOT helpful, did you check what your command will do? 2->0, 22->02, 15->05.
          – 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
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1390132%2fwindows-bulk-rename-middle-filename-via-cli%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        13














        Would it be possible to bulk rename it with Windows ren or rename tool?



        Yes, but it requires a batch file.



        test.cmd:



        @echo off
        setlocal EnableDelayedExpansion
        for /f "tokens=1,2,3,4" %%i in ('dir /b *Example.txt') do (
        rem pad 2nd token with leading zero
        set _num=0%%j
        set _num=!_num:~-2!
        ren "%%i %%j %%k %%l" "%%i !_num! %%k %%l"
        )
        endlocal


        example:



        > dir *Example.txt
        Volume in drive F is Expansion
        Volume Serial Number is 3656-BB63

        Directory of F:testtest

        03/01/2019 11:30 0 File 15 - Example.txt
        03/01/2019 11:30 0 File 2 - Example.txt
        03/01/2019 11:30 0 File 22 - Example.txt
        03/01/2019 11:30 0 File 3 - Example.txt
        03/01/2019 11:30 0 File 4 - Example.txt
        03/01/2019 11:30 0 File 5 - Example.txt
        6 File(s) 0 bytes
        0 Dir(s) 1,075,134,230,528 bytes free

        > ..test

        > dir
        Volume in drive F is Expansion
        Volume Serial Number is 3656-BB63

        Directory of F:testtest

        03/01/2019 11:54 <DIR> .
        03/01/2019 11:54 <DIR> ..
        03/01/2019 11:30 0 File 02 - Example.txt
        03/01/2019 11:30 0 File 03 - Example.txt
        03/01/2019 11:30 0 File 04 - Example.txt
        03/01/2019 11:30 0 File 05 - Example.txt
        03/01/2019 11:30 0 File 15 - Example.txt
        03/01/2019 11:30 0 File 22 - Example.txt
        6 File(s) 0 bytes
        2 Dir(s) 1,075,134,230,528 bytes free




        Further Reading




        • An A-Z Index of the Windows CMD command line | SS64.com

        • Windows CMD Commands (categorized) - Windows CMD - SS64.com

        • Dir - list files and folders - Windows CMD - SS64.com

        • EnableDelayedExpansion - Windows CMD - SS64.com

        • For - Loop through command output - Windows CMD - SS64.com

        • variable substring - Windows CMD - SS64.com






        share|improve this answer


























          13














          Would it be possible to bulk rename it with Windows ren or rename tool?



          Yes, but it requires a batch file.



          test.cmd:



          @echo off
          setlocal EnableDelayedExpansion
          for /f "tokens=1,2,3,4" %%i in ('dir /b *Example.txt') do (
          rem pad 2nd token with leading zero
          set _num=0%%j
          set _num=!_num:~-2!
          ren "%%i %%j %%k %%l" "%%i !_num! %%k %%l"
          )
          endlocal


          example:



          > dir *Example.txt
          Volume in drive F is Expansion
          Volume Serial Number is 3656-BB63

          Directory of F:testtest

          03/01/2019 11:30 0 File 15 - Example.txt
          03/01/2019 11:30 0 File 2 - Example.txt
          03/01/2019 11:30 0 File 22 - Example.txt
          03/01/2019 11:30 0 File 3 - Example.txt
          03/01/2019 11:30 0 File 4 - Example.txt
          03/01/2019 11:30 0 File 5 - Example.txt
          6 File(s) 0 bytes
          0 Dir(s) 1,075,134,230,528 bytes free

          > ..test

          > dir
          Volume in drive F is Expansion
          Volume Serial Number is 3656-BB63

          Directory of F:testtest

          03/01/2019 11:54 <DIR> .
          03/01/2019 11:54 <DIR> ..
          03/01/2019 11:30 0 File 02 - Example.txt
          03/01/2019 11:30 0 File 03 - Example.txt
          03/01/2019 11:30 0 File 04 - Example.txt
          03/01/2019 11:30 0 File 05 - Example.txt
          03/01/2019 11:30 0 File 15 - Example.txt
          03/01/2019 11:30 0 File 22 - Example.txt
          6 File(s) 0 bytes
          2 Dir(s) 1,075,134,230,528 bytes free




          Further Reading




          • An A-Z Index of the Windows CMD command line | SS64.com

          • Windows CMD Commands (categorized) - Windows CMD - SS64.com

          • Dir - list files and folders - Windows CMD - SS64.com

          • EnableDelayedExpansion - Windows CMD - SS64.com

          • For - Loop through command output - Windows CMD - SS64.com

          • variable substring - Windows CMD - SS64.com






          share|improve this answer
























            13












            13








            13






            Would it be possible to bulk rename it with Windows ren or rename tool?



            Yes, but it requires a batch file.



            test.cmd:



            @echo off
            setlocal EnableDelayedExpansion
            for /f "tokens=1,2,3,4" %%i in ('dir /b *Example.txt') do (
            rem pad 2nd token with leading zero
            set _num=0%%j
            set _num=!_num:~-2!
            ren "%%i %%j %%k %%l" "%%i !_num! %%k %%l"
            )
            endlocal


            example:



            > dir *Example.txt
            Volume in drive F is Expansion
            Volume Serial Number is 3656-BB63

            Directory of F:testtest

            03/01/2019 11:30 0 File 15 - Example.txt
            03/01/2019 11:30 0 File 2 - Example.txt
            03/01/2019 11:30 0 File 22 - Example.txt
            03/01/2019 11:30 0 File 3 - Example.txt
            03/01/2019 11:30 0 File 4 - Example.txt
            03/01/2019 11:30 0 File 5 - Example.txt
            6 File(s) 0 bytes
            0 Dir(s) 1,075,134,230,528 bytes free

            > ..test

            > dir
            Volume in drive F is Expansion
            Volume Serial Number is 3656-BB63

            Directory of F:testtest

            03/01/2019 11:54 <DIR> .
            03/01/2019 11:54 <DIR> ..
            03/01/2019 11:30 0 File 02 - Example.txt
            03/01/2019 11:30 0 File 03 - Example.txt
            03/01/2019 11:30 0 File 04 - Example.txt
            03/01/2019 11:30 0 File 05 - Example.txt
            03/01/2019 11:30 0 File 15 - Example.txt
            03/01/2019 11:30 0 File 22 - Example.txt
            6 File(s) 0 bytes
            2 Dir(s) 1,075,134,230,528 bytes free




            Further Reading




            • An A-Z Index of the Windows CMD command line | SS64.com

            • Windows CMD Commands (categorized) - Windows CMD - SS64.com

            • Dir - list files and folders - Windows CMD - SS64.com

            • EnableDelayedExpansion - Windows CMD - SS64.com

            • For - Loop through command output - Windows CMD - SS64.com

            • variable substring - Windows CMD - SS64.com






            share|improve this answer












            Would it be possible to bulk rename it with Windows ren or rename tool?



            Yes, but it requires a batch file.



            test.cmd:



            @echo off
            setlocal EnableDelayedExpansion
            for /f "tokens=1,2,3,4" %%i in ('dir /b *Example.txt') do (
            rem pad 2nd token with leading zero
            set _num=0%%j
            set _num=!_num:~-2!
            ren "%%i %%j %%k %%l" "%%i !_num! %%k %%l"
            )
            endlocal


            example:



            > dir *Example.txt
            Volume in drive F is Expansion
            Volume Serial Number is 3656-BB63

            Directory of F:testtest

            03/01/2019 11:30 0 File 15 - Example.txt
            03/01/2019 11:30 0 File 2 - Example.txt
            03/01/2019 11:30 0 File 22 - Example.txt
            03/01/2019 11:30 0 File 3 - Example.txt
            03/01/2019 11:30 0 File 4 - Example.txt
            03/01/2019 11:30 0 File 5 - Example.txt
            6 File(s) 0 bytes
            0 Dir(s) 1,075,134,230,528 bytes free

            > ..test

            > dir
            Volume in drive F is Expansion
            Volume Serial Number is 3656-BB63

            Directory of F:testtest

            03/01/2019 11:54 <DIR> .
            03/01/2019 11:54 <DIR> ..
            03/01/2019 11:30 0 File 02 - Example.txt
            03/01/2019 11:30 0 File 03 - Example.txt
            03/01/2019 11:30 0 File 04 - Example.txt
            03/01/2019 11:30 0 File 05 - Example.txt
            03/01/2019 11:30 0 File 15 - Example.txt
            03/01/2019 11:30 0 File 22 - Example.txt
            6 File(s) 0 bytes
            2 Dir(s) 1,075,134,230,528 bytes free




            Further Reading




            • An A-Z Index of the Windows CMD command line | SS64.com

            • Windows CMD Commands (categorized) - Windows CMD - SS64.com

            • Dir - list files and folders - Windows CMD - SS64.com

            • EnableDelayedExpansion - Windows CMD - SS64.com

            • For - Loop through command output - Windows CMD - SS64.com

            • variable substring - Windows CMD - SS64.com







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            DavidPostill

            103k25224258




            103k25224258

























                17














                This PowerShell one liner will expand all numbers in the file name to two places .PadLeft(2,'0'):

                (and leave numbers with more places untouched)



                Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}


                to be on topic, wrapped in a cmd line/batch file:



                Powershell -Nop -C "Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}"


                To be on the safe side before executing the commands, append either





                • -Confirm which asks before doing a rename


                • -WhatIfwhich lists all renames it would execute without the parameter


                just in front of the last "






                share|improve this answer




























                  17














                  This PowerShell one liner will expand all numbers in the file name to two places .PadLeft(2,'0'):

                  (and leave numbers with more places untouched)



                  Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}


                  to be on topic, wrapped in a cmd line/batch file:



                  Powershell -Nop -C "Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}"


                  To be on the safe side before executing the commands, append either





                  • -Confirm which asks before doing a rename


                  • -WhatIfwhich lists all renames it would execute without the parameter


                  just in front of the last "






                  share|improve this answer


























                    17












                    17








                    17






                    This PowerShell one liner will expand all numbers in the file name to two places .PadLeft(2,'0'):

                    (and leave numbers with more places untouched)



                    Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}


                    to be on topic, wrapped in a cmd line/batch file:



                    Powershell -Nop -C "Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}"


                    To be on the safe side before executing the commands, append either





                    • -Confirm which asks before doing a rename


                    • -WhatIfwhich lists all renames it would execute without the parameter


                    just in front of the last "






                    share|improve this answer














                    This PowerShell one liner will expand all numbers in the file name to two places .PadLeft(2,'0'):

                    (and leave numbers with more places untouched)



                    Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}


                    to be on topic, wrapped in a cmd line/batch file:



                    Powershell -Nop -C "Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([regex]::Replace($_.BaseName,'d+',{$args[0].Value.PadLeft(2,'0')}))+$_.Extension}"


                    To be on the safe side before executing the commands, append either





                    • -Confirm which asks before doing a rename


                    • -WhatIfwhich lists all renames it would execute without the parameter


                    just in front of the last "







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 17 hours ago

























                    answered yesterday









                    LotPings

                    4,6461722




                    4,6461722























                        3














                        Edit: I've just noticed this question is specifically about renaming from the command line, so it does not answer the question directly... I'll keep it for now, hoping it will be useful for others.





                        The Total Commander file manager has an excellent bulk rename tool. It includes many features, including rename preview, different rename masks, regular expressions, renaming files in entire folder hierarcy, and much more. At the same time, it is quite easy to use.



                        Here's a screenshot for demonstrating its usage:



                        Total Commander Multi Rename Example



                        Step by step:





                        1. Download and run Total Commander.

                        2. Nativate to the folder with the files to rename.

                        3. Mark the files to rename:


                          • Option 1 - Ctrl + A for marking all files in the folder.

                          • Option 2 - Mark files one by one, using the Space key or mouse right click.

                          • Option 3 - Open "Find Files" (Alt + F7), type *.txt in the "Search for" box, click "Start Search", press "Feed to listbox", then mark the files with Ctrl + A.
                            Use this technique if you want to rename files also in inner folders.



                        4. Press Ctrl + M to open the Multi-Rename tool.

                        5. Set the desired values in "Search for" and "Replace with" boxes. If using a regular expression, check the RegEx box.

                        6. Hit "Start!".






                        share|improve this answer




























                          3














                          Edit: I've just noticed this question is specifically about renaming from the command line, so it does not answer the question directly... I'll keep it for now, hoping it will be useful for others.





                          The Total Commander file manager has an excellent bulk rename tool. It includes many features, including rename preview, different rename masks, regular expressions, renaming files in entire folder hierarcy, and much more. At the same time, it is quite easy to use.



                          Here's a screenshot for demonstrating its usage:



                          Total Commander Multi Rename Example



                          Step by step:





                          1. Download and run Total Commander.

                          2. Nativate to the folder with the files to rename.

                          3. Mark the files to rename:


                            • Option 1 - Ctrl + A for marking all files in the folder.

                            • Option 2 - Mark files one by one, using the Space key or mouse right click.

                            • Option 3 - Open "Find Files" (Alt + F7), type *.txt in the "Search for" box, click "Start Search", press "Feed to listbox", then mark the files with Ctrl + A.
                              Use this technique if you want to rename files also in inner folders.



                          4. Press Ctrl + M to open the Multi-Rename tool.

                          5. Set the desired values in "Search for" and "Replace with" boxes. If using a regular expression, check the RegEx box.

                          6. Hit "Start!".






                          share|improve this answer


























                            3












                            3








                            3






                            Edit: I've just noticed this question is specifically about renaming from the command line, so it does not answer the question directly... I'll keep it for now, hoping it will be useful for others.





                            The Total Commander file manager has an excellent bulk rename tool. It includes many features, including rename preview, different rename masks, regular expressions, renaming files in entire folder hierarcy, and much more. At the same time, it is quite easy to use.



                            Here's a screenshot for demonstrating its usage:



                            Total Commander Multi Rename Example



                            Step by step:





                            1. Download and run Total Commander.

                            2. Nativate to the folder with the files to rename.

                            3. Mark the files to rename:


                              • Option 1 - Ctrl + A for marking all files in the folder.

                              • Option 2 - Mark files one by one, using the Space key or mouse right click.

                              • Option 3 - Open "Find Files" (Alt + F7), type *.txt in the "Search for" box, click "Start Search", press "Feed to listbox", then mark the files with Ctrl + A.
                                Use this technique if you want to rename files also in inner folders.



                            4. Press Ctrl + M to open the Multi-Rename tool.

                            5. Set the desired values in "Search for" and "Replace with" boxes. If using a regular expression, check the RegEx box.

                            6. Hit "Start!".






                            share|improve this answer














                            Edit: I've just noticed this question is specifically about renaming from the command line, so it does not answer the question directly... I'll keep it for now, hoping it will be useful for others.





                            The Total Commander file manager has an excellent bulk rename tool. It includes many features, including rename preview, different rename masks, regular expressions, renaming files in entire folder hierarcy, and much more. At the same time, it is quite easy to use.



                            Here's a screenshot for demonstrating its usage:



                            Total Commander Multi Rename Example



                            Step by step:





                            1. Download and run Total Commander.

                            2. Nativate to the folder with the files to rename.

                            3. Mark the files to rename:


                              • Option 1 - Ctrl + A for marking all files in the folder.

                              • Option 2 - Mark files one by one, using the Space key or mouse right click.

                              • Option 3 - Open "Find Files" (Alt + F7), type *.txt in the "Search for" box, click "Start Search", press "Feed to listbox", then mark the files with Ctrl + A.
                                Use this technique if you want to rename files also in inner folders.



                            4. Press Ctrl + M to open the Multi-Rename tool.

                            5. Set the desired values in "Search for" and "Replace with" boxes. If using a regular expression, check the RegEx box.

                            6. Hit "Start!".







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited yesterday

























                            answered yesterday









                            valiano

                            1838




                            1838























                                -2














                                ren *.bat *.txt will work to rename extensions on all matching files retaining the other portion of the name. Could you not abuse this to run a sequence of ren commands?





                                • ren "File *" "File 0*"

                                • ren "File 00*" "File 0*"

                                • (deal with dangling remainders like File 022 - Example.txt






                                share|improve this answer





















                                • This is NOT helpful, did you check what your command will do? 2->0, 22->02, 15->05.
                                  – LotPings
                                  yesterday
















                                -2














                                ren *.bat *.txt will work to rename extensions on all matching files retaining the other portion of the name. Could you not abuse this to run a sequence of ren commands?





                                • ren "File *" "File 0*"

                                • ren "File 00*" "File 0*"

                                • (deal with dangling remainders like File 022 - Example.txt






                                share|improve this answer





















                                • This is NOT helpful, did you check what your command will do? 2->0, 22->02, 15->05.
                                  – LotPings
                                  yesterday














                                -2












                                -2








                                -2






                                ren *.bat *.txt will work to rename extensions on all matching files retaining the other portion of the name. Could you not abuse this to run a sequence of ren commands?





                                • ren "File *" "File 0*"

                                • ren "File 00*" "File 0*"

                                • (deal with dangling remainders like File 022 - Example.txt






                                share|improve this answer












                                ren *.bat *.txt will work to rename extensions on all matching files retaining the other portion of the name. Could you not abuse this to run a sequence of ren commands?





                                • ren "File *" "File 0*"

                                • ren "File 00*" "File 0*"

                                • (deal with dangling remainders like File 022 - Example.txt







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered yesterday









                                Douglas Held

                                1374




                                1374












                                • This is NOT helpful, did you check what your command will do? 2->0, 22->02, 15->05.
                                  – LotPings
                                  yesterday


















                                • This is NOT helpful, did you check what your command will do? 2->0, 22->02, 15->05.
                                  – LotPings
                                  yesterday
















                                This is NOT helpful, did you check what your command will do? 2->0, 22->02, 15->05.
                                – LotPings
                                yesterday




                                This is NOT helpful, did you check what your command will do? 2->0, 22->02, 15->05.
                                – LotPings
                                yesterday


















                                draft saved

                                draft discarded




















































                                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.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • 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%2f1390132%2fwindows-bulk-rename-middle-filename-via-cli%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

                                How to make a Squid Proxy server?

                                Is this a new Fibonacci Identity?

                                19世紀