Rename multiple files without parentheses/remove parentheses windows

后端 未结 4 1956
情深已故
情深已故 2021-02-06 03:03

I want to rename a large number of files in increasing order of numbers, starting from anywhere. But when I rename multiple files, it leaves me with parentheses. eg i rename f

4条回答
  •  臣服心动
    2021-02-06 03:49

    A bit late to the party, but here's a combination of removing parentheses and the empty space automatically created. This code works by having the .bat file inside a folder containing all the files you'd like to modify.

    Copy and paste the code in notepad and save it as sequentialFileNameCleaner.bat

    Your file name must be the same as what is written on the first line sequentialFileNameCleaner.bat. That being said, you can manually update the first line if you want to change the file name.

    :sequentialFileNameCleaner  [/R]  [FolderPath]
    setlocal enabledelayedexpansion
    for %%a in (*.jpg) do (
    set f=%%a
    set f=!f:^(=!
    set f=!f:^)=!
    ren "%%a" "!f!"
    )
    @echo off
    setlocal disableDelayedExpansion
    if /i "%~1"=="/R" (
      set "forOption=%~1 %2"
      set "inPath="
    ) else (
      set "forOption="
      if "%~1" neq "" (set "inPath=%~1\") else set "inPath="
    )
    for %forOption% %%F in ("%inPath%* *") do (
      if /i "%~f0" neq "%%~fF" (
        set "folder=%%~dpF"
        set "file=%%~nxF"
        setlocal enableDelayedExpansion
        echo ren "!folder!!file!" "!file: =!"
        ren "!folder!!file!" "!file: =!"
        endlocal
      )
    
    )
    

    By default, this code will only locate .jpg files. On the 3rd line, changing the (*.jpg) to (*.png) or to (*.mp4) or any extension you'd like will make the code compatible.

提交回复
热议问题