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

后端 未结 11 1745
南方客
南方客 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:40

    I know this is so old, but i've landed on it , and the provided answers didn't works for me on powershell so after searching found this solution

    to do it in powershell

    Get-ChildItem -Path C:\Demo -Filter *.txt | Rename-Item -NewName {[System.IO.Path]::ChangeExtension($_.Name, ".old")}
    

    credit goes to http://powershell-guru.com/powershell-tip-108-bulk-rename-extensions-of-files/

    0 讨论(0)
  • 2020-12-07 08:43

    In my case I had a directory with 800+ files ending with .StoredProcedure.sql (they were scripted with SSMS).

    The solutions posted above didn't work. But I came up with this:

    (Based on answers to batch programming - get relative path of file)

    @echo off
    setlocal enabledelayedexpansion
    for %%f in (*) do (
      set B=%%f
      set B=!B:%CD%\=!
      ren "!B!" "!B:.StoredProcedure=!"
    )
    

    The above script removes the substring .StoredProcedure from the filename. I'm sure it can be adapted to cover more cases, ask for input and be overall more generic.

    0 讨论(0)
  • 2020-12-07 08:47

    Rename multiple file extensions:

    You want to change ringtone1.mp3, ringtone2.mp3 to ringtone1.wav, ringtone2.wav

    Here is how to do that: I am in d drive on command prompt (CMD) so I use:

    d:\>ren *.* *.wav 
    

    This is just an example of file extensions, you can use any type of file extension like WAV, MP3, JPG, GIF, bmp, PDF, DOC, DOCX, TXT this depends on what your operating system.

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

    0 讨论(0)
  • 2020-12-07 08:48

    on CMD

    type

    ren *.* *.jpg
    

    . will select all files, and rename to * (what ever name they have) plus extension to jpg

    0 讨论(0)
  • 2020-12-07 08:50

    An alternative way to rename files using the renamer npm package.

    below is an example of renaming files extensions

    renamer -d --path-element ext --find ts --replace js *
    
    0 讨论(0)
提交回复
热议问题