2


我有这部分批处理脚本正在执行以下操作:
-有一个主文件夹,主文件夹中有两个文件(电影和字幕文件)和一个名为“字幕”的子文件夹

-此脚本采用电影的名称文件并用它重命名字幕文件+将字幕文件移动到“字幕”子文件夹中,然后重命名主文件夹。所以最后我们有一个电影名称,用于字幕文件和主文件夹。

@echo off
setlocal EnableDelayedExpansion


cd /D "%~DP0"
echo BASE FOLDER: %cd%
set n=0
for /D %%a in (*) do (
set /A n+=1
cd "%%a"
echo ==================================================================
echo Processing folder: %%a


for %%b in (*.avi *.mp4 *.mkv) do set movieName=%%~Nb
echo Movie name: !movieName!
for %%b in (*.srt *.sub) do (
   move "%%b" "Subtitles\!movieName!%%~Xb"
  echo File "%%b" moved and renamed to "Subtitles\!movieName!%%~Xb"
)


cd ..
ren "%%a" "!movieName!"
echo Folder "%%a" renamed to "!movieName!" 

)
echo ==================================================================
echo %n% FOLDERS PROCESSED
pause

!!!!!!我需要的是:!!!!!!
-我需要反之亦然,因此名称将取自主文件夹而不是电影文件,因此主文件夹的名称将用于电影和字幕文件

谢谢!

4

1 回答 1

3
@echo off
setlocal EnableDelayedExpansion


cd /D "%~DP0"
echo BASE FOLDER: %cd%
set n=0
for /D %%a in (*) do (
set /A n+=1
cd "%%a"
echo ==================================================================
echo Processing folder: %%a
set movieName=%%~a


for %%b in (*.avi *.mp4 *.mkv) do (
   ren "%%~b" "!movieName!%%~Xb"
   echo Movie file "%%b" renamed to "!movieName!%%~Xb"
)

for %%b in (*.srt *.sub) do (
   move "%%~b" "Subtitles\!movieName!%%~Xb"
   echo File "%%b" moved and renamed to "Subtitles\!movieName!%%~Xb"
)


cd ..

)
echo ==================================================================
echo %n% FOLDERS PROCESSED
pause
于 2012-12-27T19:49:54.653 回答