You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

批量将电影文件夹重命名为内部电影文件名的实现方法及示例咨询

批量将电影文件夹重命名为内部电影文件名的实现方法及示例咨询

Hey there! I totally get your frustration—having perfectly named movie files stuck inside mismatched folders is such a nuisance. Let's figure out how to fix this properly, since the basic RENAME command alone won't handle the batch, automated part you need.

First, let's address your question about the RENAME command: yes, it can rename folders, but it only works for single items. To batch-rename all your movie folders to match their internal file names, we'll need a small Windows batch script that loops through each folder, grabs the correct file name, and renames the folder accordingly.

Here's a ready-to-use batch script with explanations:

@echo off
setlocal enabledelayedexpansion

:: Replace this path with your main movies directory (e.g., D:\MyMovieCollection)
set "mainMovieDir=D:\MyMovieCollection"

:: Loop through every subfolder in your main movie directory
for /d %%folder in ("%mainMovieDir%\*") do (
    :: Loop through common movie file formats inside each folder (add more if needed)
    for %%file in ("%%folder\*.mp4" "%%folder\*.mkv" "%%folder\*.avi" "%%folder\*.mov") do (
        :: Get the file name without its extension
        set "correctName=%%~nfile"
        :: Check if the current folder name doesn't match the file name
        if not "%%~nfolder"=="!correctName!" (
            :: Show what's being renamed (remove the "echo" line if you don't want previews)
            echo Renaming folder "%%~nfolder" to "!correctName!"
            :: Actually perform the rename
            rename "%%folder" "!correctName!"
            :: Exit the inner loop once we find the first movie file (assumes 1 file per folder)
            goto :nextFolder
        )
    )
    :nextFolder
)

echo All folder renames are complete!
pause

How to use this script:

  • Backup first! Always make a copy of your movie folders before running batch rename scripts—just in case something goes wrong.
  • Edit the main directory path: Change set "mainMovieDir=D:\MyMovieCollection" to point to the folder that contains all your movie subfolders.
  • Add/remove file formats: If your movies use other formats (like .flv or .wmv), add them to the inner loop's list (e.g., "%%folder\*.flv").
  • Run the script: Save the code as RenameMovieFolders.bat, double-click it, and it will process all folders automatically.

Example scenario:

Suppose you have:

  • D:\MyMovieCollection\Old_Folder_Name_1 containing Inception (2010).mkv
  • D:\MyMovieCollection\RandomFolderName containing Parasite (2019).mp4

After running the script, the folders will be renamed to:

  • Inception (2010)
  • Parasite (2019)

Key notes:

  • This script assumes each movie folder contains exactly one movie file. If there are multiple files in a folder, it will use the first one it finds (based on file extension order).
  • The echo line lets you preview changes before they happen—you can remove it once you're sure the script works as expected.

Hopefully this solves your problem! Let me know if you run into any hiccups.

备注:内容来源于stack exchange,提问作者PCRuns

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 15:28:00