View Full Version : Help coding advanced batch file (DOS)
ADLANCAS
26th May 2005, 02:35
Hi,
I´ve put a thread in DVD Rebuilder area, but maybe here a better place to put, since this is basically a DOS command line thema. And there I had no help:(
I think about using rejig in a batch file (.bat).
All my encodes are made in this .bat, like this:
"C:\Arquivos de programas\Custom Technology\CCE SP Trial Version\cctspt.exe" -ecl "D:\cce.ecl" -batch
I have not so much knowledges in batch files, but the idea is:
-checks the size of all files *.m2v in drive D:\;
-compare the sum of them to 4000MB;
-resize if greater then x%, to fit 4000MB;
Could someone help to code this batch file ?
Thanks,
Alexandre
PS. Moderator, please fell free to move to another thread if it´s necessary and sorry if I made a mistake.
int 21h
26th May 2005, 07:34
Não sei se isso é possível. Terceira parte é o mais difícil. O que é mau com DVDRebuilder?
(I don't know if that is possible. The third part is the most difficult. What is bad with DVDRebuilder?)
Wilbert
26th May 2005, 09:24
Não sei se isso é possível. Terceira parte é o mais difícil. O que é mau com DVDRebuilder?
Which translates to?
very roughly:
I don't think it's possible. The third part is the most difficult. What's wrong with using DVD Rebuilder?
int21 knows better than to reply in a foreign language, it's against forum rules...
-Nic
buzzqw
26th May 2005, 10:39
mmm , look at this
SET SIZE1=0
SET SIZE=0
FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A SIZE1=%%i+%SIZE1%
SET /A HIT=(%SIZE1%/4194304000)*100
IF %HIT% GEQ 101 SET /A HIT=%HIT%-100
IF %HIT% GEQ 1 FOR /F "tokens=*" %%i in ("rejig.exe -level %HIT% -o %LIST% -i d:\movie.mv2 -close -quiet -auto") DO CALL START /MIN /LOW /WAIT %%i
dunno if is correct i cannot test in this moment
but hope that helps !
BHH
ADLANCAS
26th May 2005, 15:17
Hi,
@Int 21h,
What´s wrong with DVD Rebuilder? I don´t know, because I´ve never used. Makes sense to use it for what I need ?
@Nic
Do you speak portuguese ?:D
@buzzqw
Thanks a lot. I´ll test, and try to understand it.
It´d help if you could explain the code a little bit:)
Alexandre
buzzqw
26th May 2005, 15:51
SET SIZE1=0 ->set variable size :D
SET SIZE=0 ->set variable size :D
FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt --> create file named size.txt with only the size of each file, in byte
FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt --> create a file named list.txt with only the names of all file m2v. The file is like "d:\1.m2v + d:\2.m2v + ..."
FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i --> since rejig do not want a file list with all file to work, i must do something..., so i type list.txt into a variable named %LIST%
FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A SIZE1=%%i+%SIZE1% --> the wrong part (i think). Sum all values (typed into size.txt) in %SIZE1%
SET /A HIT=(%SIZE1%/4194304000)*100 --> get the % between sum_size and 4000mb*1024kb*1024byte
IF %HIT% GEQ 101 SET /A HIT=%HIT%-100 --> if % >= 101, decrease by 100. This is the reduction factor for Rejig
IF %HIT% GEQ 1 FOR /F "tokens=*" %%i in ("rejig.exe -level %HIT% -o %LIST% -i d:\movie.mv2 -close -quiet -auto") DO CALL START /MIN /LOW /WAIT %%i --> launch rejig, minimized, in low priority, and wait to launch other task
BHH
Arachnotron
26th May 2005, 15:55
That script won't work, since dir/b will only show the file names, not the sizes.
The script below get's the sizes and filenames from a dir.
Attention! after delims there is a tab, followed by a space.
put your own stuff in the process subroutine to do something with the filenames and sizes in %3 and %2 resp.
@echo off
FOR /F "tokens=1-4 skip=7delims= " %%I in ('DIR /-C *.mv2') do call :process %%J %%K %%L
%%M
goto :EOF
:process
if /I "%1" == "File(s)" goto :eof
if /I "%1" == "Dir(s)" goto :eof
echo size of %3 = %2 bytes
goto :eof
that smily is a : followed by process. The forum turns that into :process
buzzqw
26th May 2005, 16:20
just a note
%%~zi is file size
BHH
ADLANCAS
26th May 2005, 17:53
@buzzqw
I put only first 3 lines to see the file size.txt but didn´t work:
SET SIZE1=0
SET SIZE=0
FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
pause
@Arachnotron
It works, but I´m totally limited to continue this code. I´ve put a pause to see what´s happen.
REM @echo off
FOR /F "tokens=1-4 skip=7delims= " %%I in ('DIR /-C D:\*.m2v') do call :process %%J %%K %%L
%%M
goto :EOF
:process
if /I "%1" == "File(s)" goto :eof
if /I "%1" == "Dir(s)" goto :eof
echo size of %3 = %2 bytes
pause
goto :eof
buzzqw
26th May 2005, 19:36
FOR %%i in (DIR /B D:\*.m2v) DO ECHO %%~zi >>D:\size.txt
BHH
Doobie
26th May 2005, 22:00
I'm sure someone's happy that his ancient DOS *.bat skills are in demand.
Arachnotron
26th May 2005, 23:06
I'm sure someone's happy that his ancient DOS *.bat skills are in demand.Actually, this stuff only works with the extended support available in Windows NT and higher, it would never run under true DOS :)
@buzzqw
You are perfectly right, My bad :) ~z indeed expands a variable holding a filename to it's size.
@adlancas
see
http://www.ss64.com/nt/for.html
and
http://www.ss64.com/ntsyntax/parameters.html
for more info
int 21h
27th May 2005, 02:09
Originally posted by Nic
very roughly:
I don't think it's possible. The third part is the most difficult. What's wrong with using DVD Rebuilder?
int21 knows better than to reply in a foreign language, it's against forum rules...
-Nic
Ack, sorry, I have seen so many threads with fragments of various languages I didn't think to read the rules and see that !English is not allowed.
Honestly, I was just goofing around trying to produce Portuguese, won't do it again.
markrb
27th May 2005, 02:42
I never saw having another language written here as any problem as long as a translation to English is provided in the same post. This way all parties know what you are talking about and can learn.
I may not be right here so don't shoot me.
Mark
ADLANCAS
30th May 2005, 03:24
@Arachnotron
Thanks for the links. I´ll check them.
@buzzqw
I saw 3 things:
- Sum doesn´t work (as you suppose);
- In the line SET /A HIT=(%SIZE1%/4194304000)*100 , it seems that variable HIT is a integer. It should be a real value;
- Line for rejig doesn´t work.I´m trying to find help for rejig command line. I´ve made a big searched, but until now I didn´t find out.
I´ll continue to test and learn. ;)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.