美好的一天,
我有一个包含电影文件夹的文件夹。在每个文件夹中,有视频文件,.srt用于字幕,jpg用于海报,最后我包括预告片用于上述电影。
我想要一个批处理文件:
将我的所有“.mp4 .mkv .avi”电影文件以及“.srt”重命名为其文件夹名称(因为我将此文件夹重命名为“Fight Club(1999)[1080p],所以电影文件和.srt将具有相同的名称,当然除了它的扩展名。)
将所有* .jpeg * .jpg * .png重命名为“poster.jpg或poster.png”。
将所有预告片文件重命名为“Trailer.mp4。我为每部影片放置预告片,每当你下载一部影片时,我想删除凌乱的文件名,例如”---搏击俱乐部 - #TTT预告片--20 Century FOX“并将其变成”Trailers.mp4。
排除重命名已有“预告片”文件名的内容。
每个文件夹名称将如下所示: 搏击俱乐部(1999)[1080p] .mp4,搏击俱乐部(1999)[1080p] .srt,搏击俱乐部(1999)[1080p] .nfo,poster.jpg,Trailer.mp4。
我做了这个,但我遇到了这些:
请帮助,非常感谢。
@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
except (*Trailer.mp4)
except (*Trailer.mkv)
for %%b in (*.avi *.mp4 *.mkv) do (
ren "%%~b" "!movieName!%%~Xb"
echo Movie file "%%b" renamed to "!movieName!%%~Xb"
for %%b in (*.srt *.sub *.ass *.ssa *.idx) do (
ren "%%~b" "!movieName!%%~Xb"
echo File "%%b" renamed to "!movieName!%%~Xb"
)
for %%b in (*.jpeg *.jpg *.png) do (
ren "%%~b" "!poster.jpg"
echo File "%%b" renamed to "!poster.jpg~Xb"
)
for fname in *Trailer; do
newname=`echo "$fname" | sed 's/Trailer/Trailer/g'`
sed 's/Trailer/Trailer/g' "$fname" >"$newname"
done
cd ..
)
echo ==================================================================
答案 0 :(得分:1)
也许这会有所帮助:
@echo off
setlocal EnableDelayedExpansion
cd /D "%~dp0"
echo BASE FOLDER: %cd%
set n=0
for /D %%a in (*) do (
set /A n+=1
PushD "%%a"
echo ==================================================================
echo Processing folder: %%a
set "movieName=%%~a"
rem except (*Trailer.mp4),except (*Trailer.mkv)
for /f "delims=" %%b in (
'dir /B *.avi *.mp4 *.mkv ^|findstr /i /v "Trailer" '
) do (
ren "%%~b" "!movieName!%%~Xb" && ^
echo Movie file "%%b" renamed to "!movieName!%%~Xb"
)
for %%b in (*.srt *.sub *.ass *.ssa *.idx) do (
ren "%%~b" "!movieName!%%~Xb"&& ^
echo File "%%b" renamed to "!movieName!%%~Xb"
)
for %%b in (*.jpeg *.jpg *.png) do (
ren "%%~b" "poster%%~xb" && ^
echo File "%%b" renamed to "poster%%~xb"
)
for /f "delims=" %%b in (
'dir /B "*trailer*" '
) do (
ren "%%~b" "Trailer%%~Xb" && ^
echo Movie file "%%b" renamed to "Trailer%%~Xb"
)
PopD
)
echo ==================================================================