Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

Solved: for /r help


(!)

Ehrlichia's Avatar
Ehrlichia Ehrlichia is offline
Member with 6 posts.
THREAD STARTER
 
Join Date: Jun 2012
Experience: Intermediate
07-Jul-2012, 04:24 PM #1
Solved: for /r help
I don't know if this is the best place to put this but I'm sure admin's will move it if necessary.
I use a program called mkvtoolnix to convert my kids videos from avi to mkv container. so I can place chapters, cut out unnecessary parts for viewing on the WDTV. they use winavi to capture to avi and I convert to mkv with mkvtoolnix and put chapters in with mkvchapterizer.
I reciently found out batch files could do this with just one click.
here is what I found so far

@echo off
for %%a in (*.avi) do (
"mkvmerge" -o "%%~na.mkv" -a 1 -d 0 -S "%%~na.avi" --track-order 0:0,0:1
)

this works great but just in one folder at a time. can I do this recursively in all their folders i.e. alans games,paulas vacation,
just once.
thanks.
Squashman's Avatar
Trusted Advisor with 19,684 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
09-Jul-2012, 01:40 PM #2
Code:
@echo off
for /F "delims=" %%G in ('dir /a-d /b /s *.avi') do (
	"mkvmerge" -o "%%~dpnG.mkv" -a 1 -d 0 -S "%%~G" --track-order 0:0,0:1
)
Ehrlichia's Avatar
Ehrlichia Ehrlichia is offline
Member with 6 posts.
THREAD STARTER
 
Join Date: Jun 2012
Experience: Intermediate
09-Jul-2012, 07:55 PM #3
I would like to say that this worked for me but it didn't put in a batch file or run from the cmd prompt all I got was a blip, and putting a pause in for some reason didn't work either,,?
do you have any other advice? thank-you for the rapid response Squashman.
Squashman's Avatar
Trusted Advisor with 19,684 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
10-Jul-2012, 06:49 AM #4
You need to be a little more specific on what you tried. I am not understanding you because I have to assume ENGLISH is not your native language.

Based on the information you gave me on how MKVMERGE works, I setup a batch file that will find all AVI files in a directory and its sub-directories and uses MKVMERGE to process those files.
Ehrlichia's Avatar
Ehrlichia Ehrlichia is offline
Member with 6 posts.
THREAD STARTER
 
Join Date: Jun 2012
Experience: Intermediate
10-Jul-2012, 08:59 PM #5
First thank-you, I apologize if I sounded cryptic. English Is my native language, getting what is in my head typed in this post is difficult.
I have a whole drive dedicated to my video crazed kids, on this drive there are two folders one named alan the other paula. and in those folders there are 10-15 folders each (i.e. toys,vacation, nails etc.) they both add or delete video files on a daily basis and place them in their folder depending on what was recorded.
I was asked if there was a way to add chapters like a DVD at 2-5 minute intervals (holding the fast forward on the WDTV all the time wasn't fun.) what I found was MKVToolnix and MKVChapterizer. convert the files to MKV with the batch file above, then I import all files into MKVChapterizer to add the chapters. I thought that just adding a /R to this bat file I could click once and it would do this for all folders in that directory

here is what I tried with the code you placed above. I copied from the @ symbol to the end and placed it in a new text file and renamed it convert.bat
placed it at the root of g:\ drive, double clicked it and the DOS window opened and closed quickly, I then edited the code with a PAUSE to see what came up and it still opened and closed quickly.
I then did a shift+right click and opened a command window at the root and pasted the above code, it comes back with alans was not expected at this time. I stopped and wrote the last post. once again I'm sorry I sounded cryptic your help is greatly appreciated.
Ehrlichia.
Squashman's Avatar
Trusted Advisor with 19,684 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
11-Jul-2012, 07:10 AM #6
Since you already had an existing FOR LOOP I would have thought that you would know about how to run a FOR loop from a command prompt and how to run it from a batch file.
Code:
H:\>for /?
Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

  %variable  Specifies a single letter replaceable parameter.
  (set)      Specifies a set of one or more files.  Wildcards may be used.
  command    Specifies the command to carry out for each file.
  command-parameters
             Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead
of %variable.  
So you are saying that your BATCH file works just fine when executed from one of the folders that has files that need to be converted?
When you execute your existing batch file that works, where is MKVMERGE located?
Ehrlichia's Avatar
Ehrlichia Ehrlichia is offline
Member with 6 posts.
THREAD STARTER
 
Join Date: Jun 2012
Experience: Intermediate
11-Jul-2012, 06:49 PM #7
The program is located at C:\Program Files (x86)\MKVToolNix and the for loop was something I found in a post somewhere. what I did was just copy and paste that into a batch file and it worked.
what I do now is copy and paste the batch file in every folder and double click each one to do the conversion every other day.
I assumed that the /r added after the for command would let me double click it once, and it would search through all 15 folders and convert all the avi files, I was wrong. hence my post for help.
Squashman's Avatar
Trusted Advisor with 19,684 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
12-Jul-2012, 06:32 AM #8
You shouldn't be using code you don't understand. Just because it works doesn't make it right. There really isn't much difference between my batch file and yours. All mine is doing is using the DIR command to traverse your directory structure to find all AVI files. The only way it would not execute is if it could not find the mkvmerge program. I am assuming that is in your path because your batch file works with it being in the Program Files Directory. So if your batch file works then so should mine.

Try copying and pasting this code directly into the command prompt and run it. Don't use a batch file.

Code:
for /F "delims=" %G in ('dir /a-d /b /s *.avi') do "mkvmerge" -o "%~dpnG.mkv" -a 1 -d 0 -S "%~G" --track-order 0:0,0:1
Ehrlichia's Avatar
Ehrlichia Ehrlichia is offline
Member with 6 posts.
THREAD STARTER
 
Join Date: Jun 2012
Experience: Intermediate
12-Jul-2012, 07:11 PM #9
that did the trick thank you again
I figured out what happened with the original code, I forgot to copy the end bracket to close off the batch file. it's the little things that make you feel the worst.

Last edited by Ehrlichia; 12-Jul-2012 at 07:50 PM..
Ehrlichia's Avatar
Ehrlichia Ehrlichia is offline
Member with 6 posts.
THREAD STARTER
 
Join Date: Jun 2012
Experience: Intermediate
18-Jul-2012, 08:41 PM #10
Just an update, I have now re-arranged the code to convert the files then delete the old avi file (if put into a batch file)
it works like a charm for me.

@echo off
for /F "delims=" %%G in ('dir /a-d /b /s *.avi') do (
"mkvmerge" -o "%%~dpnG.mkv" -a 1 -d 0 -S "%%~G" --track-order 0:0,0:1
)

@echo off
for /F "delims=" %%G in ('dir /a-d /b /s *.mkv') do (
del "%%~dpnG.avi"
)
Squashman's Avatar
Trusted Advisor with 19,684 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
19-Jul-2012, 07:04 AM #11
Why are you doing another FOR Loop to delete the AVI. Just do it after the MKVMERGE step in the original FOR LOOP. You are doubling the amount of time it takes for your script to run that way.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2