Rewrite the first three characters of *.ext file names in a folder with a set of lettersHow do I remove the...

Welcoming 2019 Pi day: How to draw the letter π?

Is it good practice to use Linear Least-Squares with SMA?

PTIJ: Who should I vote for? (21st Knesset Edition)

Violin - Can double stops be played when the strings are not next to each other?

What is "focus distance lower/upper" and how is it different from depth of field?

Book about superhumans hiding among normal humans

Simplify an interface for flexibly applying rules to periods of time

How are passwords stolen from companies if they only store hashes?

What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?

If I can solve Sudoku, can I solve the Travelling Salesman Problem (TSP)? If so, how?

Brexit - No Deal Rejection

Are relativity and doppler effect related?

et qui - how do you really understand that kind of phraseology?

My adviser wants to be the first author

Happy pi day, everyone!

ERC721: How to get the owned tokens of an address

Instead of a Universal Basic Income program, why not implement a "Universal Basic Needs" program?

Why did it take so long to abandon sail after steamships were demonstrated?

Why is a white electrical wire connected to 2 black wires?

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?

Why do newer 737s use two different styles of split winglets?

How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?

What is the adequate fee for a reveal operation?

Are all passive ability checks floors for active ability checks?



Rewrite the first three characters of *.ext file names in a folder with a set of letters


How do I remove the same part of a file name for many files in Windows 7?How do I rename a bunch of files in the Command Prompt?How to extract extension of input file parameter using Windows batch scriptBatch file rename with random alphanumericBatch file rename with suffix as 01 02 03 04 and so onwindows rename command to rename file.a.b to file.bMass file renaming in Bash but keeping a section of the file nameBatch file to create many files with special charactersFast NT batch script for determining path lengths in a folderWindows command line affected by AMD/Intel differences?Automatically rename uploaded files not to conflict with existing files using SFTP (WinSCP)How to call command line using vba to list file namesHow to Create individual text files from a wmic outputBatch - Do something if filename contains stringTrying to rename files based on file size













0















How to rewrite the first 3 letters of file name




  • Using set alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 to randomise characters

  • Targeting all files of a particular extension in a folder *.ext

  • Duplication of 3 characters by chance does not matter (46,656 variables already)

  • Batch script solution to run in a windows environment.

  • Prefer script to be simple to reduce run time.


Suggested code and breakdown. Note: I still have no idea how to code.





  • Original:



    032_name.ext
    039_name.ext
    0D8_name.ext
    333_other.txt



  • Write Over the top of first three characters



    XXX-name.ext



  • After



    D7K_name.ext
    L2V_name.ext
    720_name.ext
    333_other.txt



Make batch file (SetRename.bat or SetRename.cmd) then run command like:



SetRename %r *.ext   /or/ SetRename %r3%name% *.ext  /or/ SetRename




  • Code 1 adapted from DavidPostill, example of full solution



    @echo off
    setlocal enabledelayedexpansion
    rem initialise counter
    set "alphabet=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"
    rem process jpg and png files
    for /f "usebackq tokens=*" %%i in (`dir /b *.ext *.ex2`) do (
    rem split into name and extension
    set _name=[reduce 3 characters]]%%~ni
    set _ext=%%~xi
    rem do the rename
    ren "%%i" "!y!-!_name!-!_ext!"
    increment counter
    set /alphabet "%Random%"
    )
    endlocal



  • Code 2 adaptated from 3 SU posts



    @echo off

    setlocal enableextensions enabledelayedexpansion

    set "alphabet=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"

    for %%a in (%alphabet%) do (
    set "a.!name!=%%a"
    set o=-%3 [reduce by 3]

    )
    set "y="
    for /l %%a in (1 1 3) do (
    set /a "r=!random!"
    for %%b do set "y=!-%3!!r!!name!"
    )
    echo(%y%

    endlocal



Current Research:




  • SU File rename with suffix as 01 02 03 04 etc (and Further Reading)

  • SU How do I isolate filename and extension from %1?

  • SU Rename files by command line

  • SU Rename Files Random Batch File

  • SU - How do I remove the same part of a file name

  • SU Command Prompt Rename Prefix


  • Stack Overflow on Random Strings: Link 1 Link 2 Link 3

  • ss64 - Random Syntax

  • ss64 - REN Rename Command

  • wikibooks - Windows Programming/Programming CMD

  • Informit - Windows Batch Files

  • techguy - Random Numbers and Letters










share|improve this question





























    0















    How to rewrite the first 3 letters of file name




    • Using set alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 to randomise characters

    • Targeting all files of a particular extension in a folder *.ext

    • Duplication of 3 characters by chance does not matter (46,656 variables already)

    • Batch script solution to run in a windows environment.

    • Prefer script to be simple to reduce run time.


    Suggested code and breakdown. Note: I still have no idea how to code.





    • Original:



      032_name.ext
      039_name.ext
      0D8_name.ext
      333_other.txt



    • Write Over the top of first three characters



      XXX-name.ext



    • After



      D7K_name.ext
      L2V_name.ext
      720_name.ext
      333_other.txt



    Make batch file (SetRename.bat or SetRename.cmd) then run command like:



    SetRename %r *.ext   /or/ SetRename %r3%name% *.ext  /or/ SetRename




    • Code 1 adapted from DavidPostill, example of full solution



      @echo off
      setlocal enabledelayedexpansion
      rem initialise counter
      set "alphabet=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"
      rem process jpg and png files
      for /f "usebackq tokens=*" %%i in (`dir /b *.ext *.ex2`) do (
      rem split into name and extension
      set _name=[reduce 3 characters]]%%~ni
      set _ext=%%~xi
      rem do the rename
      ren "%%i" "!y!-!_name!-!_ext!"
      increment counter
      set /alphabet "%Random%"
      )
      endlocal



    • Code 2 adaptated from 3 SU posts



      @echo off

      setlocal enableextensions enabledelayedexpansion

      set "alphabet=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"

      for %%a in (%alphabet%) do (
      set "a.!name!=%%a"
      set o=-%3 [reduce by 3]

      )
      set "y="
      for /l %%a in (1 1 3) do (
      set /a "r=!random!"
      for %%b do set "y=!-%3!!r!!name!"
      )
      echo(%y%

      endlocal



    Current Research:




    • SU File rename with suffix as 01 02 03 04 etc (and Further Reading)

    • SU How do I isolate filename and extension from %1?

    • SU Rename files by command line

    • SU Rename Files Random Batch File

    • SU - How do I remove the same part of a file name

    • SU Command Prompt Rename Prefix


    • Stack Overflow on Random Strings: Link 1 Link 2 Link 3

    • ss64 - Random Syntax

    • ss64 - REN Rename Command

    • wikibooks - Windows Programming/Programming CMD

    • Informit - Windows Batch Files

    • techguy - Random Numbers and Letters










    share|improve this question



























      0












      0








      0








      How to rewrite the first 3 letters of file name




      • Using set alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 to randomise characters

      • Targeting all files of a particular extension in a folder *.ext

      • Duplication of 3 characters by chance does not matter (46,656 variables already)

      • Batch script solution to run in a windows environment.

      • Prefer script to be simple to reduce run time.


      Suggested code and breakdown. Note: I still have no idea how to code.





      • Original:



        032_name.ext
        039_name.ext
        0D8_name.ext
        333_other.txt



      • Write Over the top of first three characters



        XXX-name.ext



      • After



        D7K_name.ext
        L2V_name.ext
        720_name.ext
        333_other.txt



      Make batch file (SetRename.bat or SetRename.cmd) then run command like:



      SetRename %r *.ext   /or/ SetRename %r3%name% *.ext  /or/ SetRename




      • Code 1 adapted from DavidPostill, example of full solution



        @echo off
        setlocal enabledelayedexpansion
        rem initialise counter
        set "alphabet=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"
        rem process jpg and png files
        for /f "usebackq tokens=*" %%i in (`dir /b *.ext *.ex2`) do (
        rem split into name and extension
        set _name=[reduce 3 characters]]%%~ni
        set _ext=%%~xi
        rem do the rename
        ren "%%i" "!y!-!_name!-!_ext!"
        increment counter
        set /alphabet "%Random%"
        )
        endlocal



      • Code 2 adaptated from 3 SU posts



        @echo off

        setlocal enableextensions enabledelayedexpansion

        set "alphabet=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"

        for %%a in (%alphabet%) do (
        set "a.!name!=%%a"
        set o=-%3 [reduce by 3]

        )
        set "y="
        for /l %%a in (1 1 3) do (
        set /a "r=!random!"
        for %%b do set "y=!-%3!!r!!name!"
        )
        echo(%y%

        endlocal



      Current Research:




      • SU File rename with suffix as 01 02 03 04 etc (and Further Reading)

      • SU How do I isolate filename and extension from %1?

      • SU Rename files by command line

      • SU Rename Files Random Batch File

      • SU - How do I remove the same part of a file name

      • SU Command Prompt Rename Prefix


      • Stack Overflow on Random Strings: Link 1 Link 2 Link 3

      • ss64 - Random Syntax

      • ss64 - REN Rename Command

      • wikibooks - Windows Programming/Programming CMD

      • Informit - Windows Batch Files

      • techguy - Random Numbers and Letters










      share|improve this question
















      How to rewrite the first 3 letters of file name




      • Using set alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 to randomise characters

      • Targeting all files of a particular extension in a folder *.ext

      • Duplication of 3 characters by chance does not matter (46,656 variables already)

      • Batch script solution to run in a windows environment.

      • Prefer script to be simple to reduce run time.


      Suggested code and breakdown. Note: I still have no idea how to code.





      • Original:



        032_name.ext
        039_name.ext
        0D8_name.ext
        333_other.txt



      • Write Over the top of first three characters



        XXX-name.ext



      • After



        D7K_name.ext
        L2V_name.ext
        720_name.ext
        333_other.txt



      Make batch file (SetRename.bat or SetRename.cmd) then run command like:



      SetRename %r *.ext   /or/ SetRename %r3%name% *.ext  /or/ SetRename




      • Code 1 adapted from DavidPostill, example of full solution



        @echo off
        setlocal enabledelayedexpansion
        rem initialise counter
        set "alphabet=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"
        rem process jpg and png files
        for /f "usebackq tokens=*" %%i in (`dir /b *.ext *.ex2`) do (
        rem split into name and extension
        set _name=[reduce 3 characters]]%%~ni
        set _ext=%%~xi
        rem do the rename
        ren "%%i" "!y!-!_name!-!_ext!"
        increment counter
        set /alphabet "%Random%"
        )
        endlocal



      • Code 2 adaptated from 3 SU posts



        @echo off

        setlocal enableextensions enabledelayedexpansion

        set "alphabet=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"

        for %%a in (%alphabet%) do (
        set "a.!name!=%%a"
        set o=-%3 [reduce by 3]

        )
        set "y="
        for /l %%a in (1 1 3) do (
        set /a "r=!random!"
        for %%b do set "y=!-%3!!r!!name!"
        )
        echo(%y%

        endlocal



      Current Research:




      • SU File rename with suffix as 01 02 03 04 etc (and Further Reading)

      • SU How do I isolate filename and extension from %1?

      • SU Rename files by command line

      • SU Rename Files Random Batch File

      • SU - How do I remove the same part of a file name

      • SU Command Prompt Rename Prefix


      • Stack Overflow on Random Strings: Link 1 Link 2 Link 3

      • ss64 - Random Syntax

      • ss64 - REN Rename Command

      • wikibooks - Windows Programming/Programming CMD

      • Informit - Windows Batch Files

      • techguy - Random Numbers and Letters







      windows-10 command-line file-extension batch-rename prefix






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 9 mins ago









      phuclv

      9,99164093




      9,99164093










      asked 28 mins ago









      Kass MonkKass Monk

      186




      186






















          0






          active

          oldest

          votes











          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%2f1414691%2frewrite-the-first-three-characters-of-ext-file-names-in-a-folder-with-a-set-of%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1414691%2frewrite-the-first-three-characters-of-ext-file-names-in-a-folder-with-a-set-of%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...