Delerium1978
asked on
Batch Script Tweak Mark II
Following on from the awesome work paultomasi did on this question thread:
https://www.experts-exchange.com/questions/27623491/Batch-Script-Tweak.html
It's become apparent that the dvd -> digital conversion has filled up the folder making it very hard to find films you're looking for therefore I've added another folder level to split the films into sections of the alphabet. Unfortunatley, because i've done this, the batch script previously made isn't quite fit for purpose for the films section anymore. How can I amend the attached script to allow for the new folders?
Films ->
ABC
DEF
GHI
JKL
MNO
PQR
STU
VWX
YZ0
James
https://www.experts-exchange.com/questions/27623491/Batch-Script-Tweak.html
It's become apparent that the dvd -> digital conversion has filled up the folder making it very hard to find films you're looking for therefore I've added another folder level to split the films into sections of the alphabet. Unfortunatley, because i've done this, the batch script previously made isn't quite fit for purpose for the films section anymore. How can I amend the attached script to allow for the new folders?
Films ->
ABC
DEF
GHI
JKL
MNO
PQR
STU
VWX
YZ0
@echo off
setlocal enabledelayedexpansion
set "BaseDir=D:\Videos\DVD Transfer"
set "Pass[1]=-an"
set "Pass[2]=-acodec libmp3lame -ac 2 -ab 128kb -ar 44100"
path %BaseDir%\Encoding Software;%path%
for %%S in (Comedy Documentaries Films "Music Videos" Musicals TV) do (
echo Processing %%~S folder
set "Source=%BaseDir%\To Encode\%%~S"
for %%F in ("!Source!\*.mkv") do (
echo File: %%~nF
set Filename=%%~nF
set "Destination=%BaseDir%\Completed Encodes\%%~S\!Filename!"
echo TV Documentaries | findstr "%%~S" >nul && (
if "!Filename:~-7,1!"==" " (
if "!Filename:~-6,1!"=="S" (
if "!Filename:~-3,1!"=="E" (
set "Destination=%BaseDir%\Completed Encodes\%%~S\!Filename:~0,-7!\Season !Filename:~-5,2!"
) ) ) )
md "!Destination!" 2>nul
for /l %%P in (1,1,2) do (
echo Pass: %%P
ffmpeg.exe -y -i "!Source!\%%~nF.mkv" -pass %%P -passlogfile "%BaseDir%\!Filename!.log" -threads 8 -vcodec libxvid -vtag XVID -f avi -aspect 16:9 -r 25 -s 720x576 -b 1250kb -minrate 1250kb -maxrate 1250kb -bufsize 2048k !Pass[%%P]! "!Destination!\!Filename!.avi"
)
move "%BaseDir%\To Encode\%%~S\%%~nF.mkv" "%BaseDir%\To Encode\Old MKV\%%~nF.mkv"
echo.
)
)
cd %BaseDir%
del *.log
James
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@billprew
Currenly just films.
Just destination. Source will remain the same.
Yes first letter of file name will determine it.
@Qlemo - nice addition. Only problem with that is that the folder "YZ0" will house all films that start with a number, not just 0. Any way around that?
"So, do you only want to do this for the Films subfolder, no others?"
Currenly just films.
"Also, will this addition level only exist in the destination folder structure, but in the source files as well?"
Just destination. Source will remain the same.
"And will it be the first letter of the file name that determine what subfolder to look in?"
Yes first letter of file name will determine it.
@Qlemo - nice addition. Only problem with that is that the folder "YZ0" will house all films that start with a number, not just 0. Any way around that?
That was intentional, kind of fallback. What should happen with the films starting with numbers different from zero?
ASKER
@Qlemo - i'd just want them all in the YZ0 directory.
If you just want to have folders 123 456 789, add those to the FOR. You can remove my line 6 then, or change it e.g. to the Films folder.
Note: I have edited a typo in above code, not changing the logic.
Note: I have edited a typo in above code, not changing the logic.
Sorry, cross-post.
@Qlemo - nice addition. Only problem with that is that the folder "YZ0" will house all films that start with a number, not just 0. Any way around that?
That is exactly what the original code snippet is doing - all films starting with a digit will go into YZ0 folder.
i'd just want them all in the YZ0 directory.
ASKER
Missed the code snippet "if not defined Destination set "Destination=%BaseDir%\Com pleted Encodes\%%~S\YZ0\!Filename !"".
Question though, Destination is initially defined at line 17. Would this not conflict with this statement?
Question though, Destination is initially defined at line 17. Would this not conflict with this statement?
ASKER
*sigh* i need to get some sleep. You already have this covered with "set Destination=".
I'll try this out overnight and let you know the outcome. Many thanks :)
James
I'll try this out overnight and let you know the outcome. Many thanks :)
James
ASKER
Ran it last night and for some reason all films have gone into the catch all YZ0 folder. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ahhhh so the fallback was being called even if it found the folder. Will try this new snippet tonight and report back :) Many thanks.
James
James
ASKER
Excellent solution. Many thanks for your help.<br /><br />James
Also, will this addition level only exist in the destination folder structure, but in the source files as well?
And will it be the first letter of the file name that determine what subfolder to look in?
~bp