<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BeaverBlog &#187; ffmpeg</title>
	<atom:link href="http://blog.crazybeavers.se/index.php/archive/tag/ffmpeg/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.crazybeavers.se</link>
	<description>A beaver bloging about webdevelopment, XML and .Net</description>
	<lastBuildDate>Tue, 26 Jul 2011 10:59:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>For each (FOR IN) dropped file in batchfile</title>
		<link>http://blog.crazybeavers.se/index.php/archive/for-each-for-in-dropped-file-in-batchfile/</link>
		<comments>http://blog.crazybeavers.se/index.php/archive/for-each-for-in-dropped-file-in-batchfile/#comments</comments>
		<pubDate>Wed, 20 May 2009 05:22:57 +0000</pubDate>
		<dc:creator>Karl</dc:creator>
				<category><![CDATA[Code samples]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[batchfiles]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://blog.crazybeavers.se/?p=72</guid>
		<description><![CDATA[I&#8217;m a huge fan of batchfiles (.bat) in Windows. They are usually so simple to write and can help you out with automating tasks that otherwise would be a pain in your ass. As an example, here is a little file I&#8217;ve set up at work for my coworkers to be able to convert movieclips [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a huge fan of batchfiles (.bat) in Windows. They are usually so simple to write and can help you out with automating tasks that otherwise would be a pain in your ass. As an example, here is a little file I&#8217;ve set up at work for my coworkers to be able to convert movieclips to .wmv.</p>
<pre class="brush: plain; title: ;">
@echo off
&quot;J:\PathToOurMovieArchive\ffmpeg.exe&quot; -i %1 -b 1024k -vcodec wmv2 -acodec wmav2 -ar 44100 -ab 48000 -ac 1 -y %1-convertedHQ.wmv
pause
</pre>
<p>It&#8217;s simple enough. Don&#8217;t output anything and then execute ffmpeg,exe with the specified parameters taking the first of the dropped files as input. Works great and produces a wmv-movieclip in the same folder as the original file. The problem with this file is that it if you drop two files on this batch it will only convert the first one, which forces you to drag them one by one and then have them run simultaneously which might not be desirable on a slow computer.</p>
<p>To solve this problem I went to the all mighty <a href="http://www.google.com/" title="Visit Google">Google</a> and found the FOR IN command. My problem was that it I couldn&#8217;t find any samples with it working with dropped files and I couldn&#8217;t get it working by just doing FOR %i in (%*). The problem (according to the help for the FOR-command availabile in FOR /?) was that if used in a batchfile I need to designate my variable as %%i instead of %i. After changing that it all worked like charm. So this is how my batchfile ended up, it supports any number of dropped files (well I guess it has a built in limit such as 65335 or something though I&#8217;m pretty sure my coworkers won&#8217;t drop more then 10 files) and then executes each file in order and not all at once.</p>
<pre class="brush: plain; title: ;">
@echo off
for %%i in (%*) do &quot;J:\PathToOurMovieArchive\ffmpeg.exe&quot; -i %%i -b 1024k -vcodec wmv2 -acodec wmav2 -ar 44100 -ab 48000 -ac 1 -y %%i-convertedHQ.wmv
pause
</pre>
<p>I hope that this was to some help for somebody. If you have any other good tips on scripting with batchfiles then please add a comment about it as I&#8217;m always eager to learn new things with this great technique.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.crazybeavers.se/index.php/archive/for-each-for-in-dropped-file-in-batchfile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

