Changing all files' extensions in a folder with one command on Windows

后端 未结 11 1825
南方客
南方客 2020-12-07 08:00

How can I use the Windows command line to change the extensions of thousands of files to *****.jpg?

11条回答
  •  温柔的废话
    2020-12-07 08:34

    You can use ren (as in rename):

    ren *.XXX *.YYY
    

    And of course, switch XXX and YYY for the appropriate extensions. It will change from XXX to YYY. If you want to change all extensions, just use the wildcard again:

    ren *.* *.YYY
    

    One way to make this work recursively is with the FOR command. It can be used with the /R option to recursively apply a command to matching files. For example:

    for /R %x in (*.txt) do ren "%x" *.renamed

    will change all .txt extensions to .renamed recursively, starting in the current directory. %x is the variable that holds the matched file names.

    And, since you have thousands of files, make sure to wait until the cursor starts blinking again indicating that it's done working.

    Note: this works only on cmd. Won't work on Powershell or Bash

提交回复
热议问题