<?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>stealthcopter.com &#187; bash</title>
	<atom:link href="http://www.stealthcopter.com/blog/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stealthcopter.com/blog</link>
	<description>Android, Linux, Python and stealthcopters</description>
	<lastBuildDate>Sat, 24 Jul 2010 00:01:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Bash script to toggle samba on and off (and a button KDE)</title>
		<link>http://www.stealthcopter.com/blog/2010/04/bash-script-to-toggle-samba-on-and-off-and-a-button-kde/</link>
		<comments>http://www.stealthcopter.com/blog/2010/04/bash-script-to-toggle-samba-on-and-off-and-a-button-kde/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 15:38:54 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=823</guid>
		<description><![CDATA[I like using samba as a password-less method for people on a network to share and access files on my computer. This works well on a network you trust like a small home network or a small private network, however on different networks restricted access is preferred. For me this problem is solved by simply [...]]]></description>
			<content:encoded><![CDATA[<p>I like using samba as a password-less method for people on a network to share and access files on my computer. This works well on a network you trust like a small home network or a small private network, however on different networks restricted access is preferred. </p>
<p>For me this problem is solved by simply having a button to turn samba on and off. This will also have the side effect that you will not be able to access anyone else&#8217;s shares but is sufficient for my needs.</p>
<p><strong>Bash script</strong></p>
<pre name="code" class="bash">
#!/bin/bash
smb=`sudo /etc/init.d/samba status | grep running | wc -l`
if [ $smb -gt 0 ]
then
	# Stop samba
	sudo /etc/init.d/samba stop
else
	# Start samba
	sudo /etc/init.d/samba restart
fi
</pre>
<p>Where username is replaced with your username.</p>
<p>The script simply checks the status of samba to see if it is running, if it is then it is killed otherwise it is started. kdialog is used to display a notification of which toggle state we are in. </p>
<p><strong>Adding a notification (KDE)</strong></p>
<pre name="code" class="bash">
#!/bin/bash
smb=`sudo /etc/init.d/samba status | grep running | wc -l`
if [ $smb -gt 0 ]
then
	# Stop samba
	sudo /etc/init.d/samba stop
	sudo -u username kdialog --passivepopup 'Samba off' 3
else
	# Start samba
	sudo /etc/init.d/samba restart
	sudo -u username kdialog --passivepopup 'Samba on' 3
fi
</pre>
<p>We run kdialog through `sudo -u username` because when the script is run with sudo the current user will be root, and using this will cause kdialog to display an ugly notification.</p>
<p>For an example of this try running `sudo kdialog &#8220;ugly message&#8221; 3`</p>
<div id="attachment_825" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.stealthcopter.com/blog/2010/04/bash-script-to-toggle-samba-on-and-off-and-a-button-kde/uglykdialog/" rel="attachment wp-att-825"><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/03/uglykdialog.png" alt="kdialog run as root showing an ugly notification" title="kdialog run as root showing an ugly notification" width="400" height="254" class="size-full wp-image-825" /></a><p class="wp-caption-text">kdialog run as root showing an ugly notification</p></div>
<p>As opposed to `sudo -u username kdialog &#8211;passivepopup &#8216;lovly message&#8217; 3`<br />
<div id="attachment_826" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.stealthcopter.com/blog/2010/04/bash-script-to-toggle-samba-on-and-off-and-a-button-kde/nicekdialog/" rel="attachment wp-att-826"><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/03/nicekdialog.png" alt="kdialog run as user showing an pretty notification" title="kdialog run as user showing an pretty notification" width="450" height="147" class="size-full wp-image-826" /></a><p class="wp-caption-text">kdialog run as user showing an pretty notification</p></div></p>
<p><strong>Creating an icon/button (KDE)</strong><br />
You can then turn this into a button you can simply click my creating a desktop file. In KDE Right click > new > link to application. Then fill in the application tab with the information as in the following image:</p>
<div id="attachment_824" class="wp-caption aligncenter" style="width: 511px"><a href="http://www.stealthcopter.com/blog/2010/04/bash-script-to-toggle-samba-on-and-off-and-a-button-kde/desktopsamba/" rel="attachment wp-att-824"><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/03/desktopsamba.png" alt="Samba toggle desktop button configuration" title="Samba toggle desktop button configuration" width="501" height="442" class="size-full wp-image-824" /></a><p class="wp-caption-text">Samba toggle desktop button configuration</p></div>
<p>In the General tab you can give the button a name and choose the icon of your choice, click OK, and now you can drag your button to where ever you want it (taskbar, desktop, panel etc.) Then you can simple push the button to toggle samba on and off.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2010/04/bash-script-to-toggle-samba-on-and-off-and-a-button-kde/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Utilising the notification system in KDE or Gnome in bash scripts (ubuntu 9.10 / linux)</title>
		<link>http://www.stealthcopter.com/blog/2010/02/utilising-the-notification-system-in-kde-or-gnome-in-bash-scripts-ubuntu-9-10-linux/</link>
		<comments>http://www.stealthcopter.com/blog/2010/02/utilising-the-notification-system-in-kde-or-gnome-in-bash-scripts-ubuntu-9-10-linux/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 00:27:25 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=699</guid>
		<description><![CDATA[So you want to use the nice notification features available in your desktop environment (KDE or Gnome) from a script you wrote? Below explains how to do just that for the two different environments. KDE The code below will use kdialog (should be installed along with kde) to create a popup message that displays for [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to use the nice notification features available in your desktop environment (KDE or Gnome) from a script you wrote? Below explains how to do just that for the two different environments.</p>
<p><strong>KDE</strong></p>
<p>The code below will use kdialog (should be installed along with kde) to create a popup message that displays for 3 seconds before closing:</p>
<pre name="code" class="bash">
kdialog --passivepopup 'notification message!' 3
</pre>
<p>This should look like the image below:</p>
<div id="attachment_701" class="wp-caption aligncenter" style="width: 288px"><a href="http://www.stealthcopter.com/blog/2010/02/utilising-the-notification-system-in-kde-or-gnome-in-bash-scripts-ubuntu-9-10-linux/notification/" rel="attachment wp-att-701"><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/02/notification.png" alt="kdialog passive popup notification" title="kdialog passive popup notification" width="278" height="118" class="size-full wp-image-701" /></a><p class="wp-caption-text">kdialog passive popup notification</p></div>
<p>Source: <a href="http://stackoverflow.com/questions/1379804/activating-kde-4-notifications-from-bash-scripts/1379834">stackoverflow</a></p>
<p><strong>Gnome</strong></p>
<p>A similar tool is available for gnome, but to the best of my knowledge (I don&#8217;t really use gnome) you need to install a package. The libnotify-</p>
<pre name="code" class="bash">
sudo apt-get install libnotify-bin
</pre>
<p>The command notify-send can then be used to create notifications from your script.</p>
<pre name="code" class="bash">
notify-send -t 3000 "notification title" "notification text"
</pre>
<p>Where 3000 is the timeout in milliseconds (so 3 seconds). notify-send features some nice additional options such as the ability to include images eg:</p>
<pre name="code" class="bash">
notify-send -i /home/user/exampleicon.png -t 3000 "notification title" "notification text"
</pre>
<p>Source: <a href="http://coderstalk.blogspot.com/2010/02/custom-gnome-notification-for-your-apps.html">Coder&#8217;s Talk </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2010/02/utilising-the-notification-system-in-kde-or-gnome-in-bash-scripts-ubuntu-9-10-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash: Script to find active computers in a subnet using ping</title>
		<link>http://www.stealthcopter.com/blog/2010/01/bash-script-to-find-active-computers-in-a-subnet-using-ping/</link>
		<comments>http://www.stealthcopter.com/blog/2010/01/bash-script-to-find-active-computers-in-a-subnet-using-ping/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 21:44:14 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=511</guid>
		<description><![CDATA[The following is a simple bash script that will scan each ip address in a give subnet and report if they are alive (or accepting ping requests). The code creates processes for each ping so that it completes quickly rather than scanning each ip address sequentially. Create a text file called &#8220;pinger.sh&#8221; and paste the [...]]]></description>
			<content:encoded><![CDATA[<p>The following is a simple bash script that will scan each ip address in a give subnet and report if they are alive (or accepting ping requests). The code creates processes for each ping so that it completes quickly rather than scanning each ip address sequentially.</p>
<p>Create a text file called &#8220;pinger.sh&#8221; and paste the following into it:</p>
<pre name="code" class="bash">
#!/bin/sh

: ${1?"Usage: $0 ip subnet to scan. eg '192.168.1.'"}

subnet=$1
for addr in `seq 0 1 255 `; do
#   ( echo $subnet$addr)
( ping -c 3 -t 5 $subnet$addr > /dev/null &#038;&#038; echo $subnet$addr is Alive ) &#038;
done
</pre>
<p>Save and close, then it can be called from the command line like so:</p>
<pre name ="code" class="bash">
sh pinger.sh 192.168.1.
</pre>
<p>This will scan from 192.168.1.0 to 192.168.1.255 and will return something like the following:</p>
<pre name ="code" class="bash">
192.168.1.1 is Alive
192.168.1.105 is Alive
192.168.1.112 is Alive
192.168.1.149 is Alive
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2010/01/bash-script-to-find-active-computers-in-a-subnet-using-ping/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bash: Script to convert .flv to mp3</title>
		<link>http://www.stealthcopter.com/blog/2010/01/bash-script-to-convert-flv-to-mp3/</link>
		<comments>http://www.stealthcopter.com/blog/2010/01/bash-script-to-convert-flv-to-mp3/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 21:04:50 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=484</guid>
		<description><![CDATA[Flash Video (.FLV) is currently a very popular format of online videos, inparticular youtube. This post explains how to use a simple script to extract the sound from a flash video file and turn it into an mp3. In order for the script to work you will need to download ffmpeg (to decode the video) [...]]]></description>
			<content:encoded><![CDATA[<p>Flash Video (.FLV) is currently a very popular format of online videos, inparticular youtube. This post explains how to use a simple script to extract the sound from a flash video file and turn it into an mp3.</p>
<p>In order for the script to work you will need to download ffmpeg (to decode the video) and lame (to encode the mp3). This can be achieve in ubuntu by opening a terminal and running the following or alternatively you can use your package manager GUI to search and download the packages for you.</p>
<blockquote><p>
sudo apt-get install ffmpeg lame
</p></blockquote>
<p>You then need to create a new file named &#8220;flv2mp3.sh&#8221; and paste the following into it using your preferred text editor (which hopefully isn&#8217;t VI). Save the file and then change the file permissions so that it is executable (by running:`chmod a+x flv2mp3.sh` in the terminal or via the gui in you file browser)</p>
<pre name="code" class="bash">
#!/bin/sh
# this script should convert files from FLV to WAV and then to MP3
echo " "
echo "  Welcome to FLV to MP3 converter!  version 0.1"
echo " "
infile_name="$@"
# exit if the user did not enter anything:
if [ -z "$infile_name" ]; then
    echo " "
    echo "You did not tell me the file name, so I will exit now."
    echo " "
    exit
fi
echo " "
ffmpeg -i "$infile_name" -acodec pcm_s16le -ac 2 -ab 128k -vn -y "${infile_name%.flv}.wav"
lame --preset cd "${infile_name%.flv}.wav" "${infile_name%.flv}.mp3"
rm "${infile_name%.flv}.wav"
echo " "
echo "OK. I'm done! Have fun!"
echo " "
exit
</pre>
<p>You should now be able to convert a flashvideo into an mp3 by running the following command (changing the filenames to fit your purpose):<br />
<code>sh flv2mp3.sh videofilename.flv mp3audiofilename.mp3</code></p>
<p><strong>Extra: Youtube</strong><br />
In linux it might be worth noting that youtube downloads the flv&#8217;s to your /tmp folder and you can easily copy them or convert to mp3&#8242;s (Ensure video is completly finished loading).</p>
<p>Also there is an application called &#8216;youtube-dl&#8217; which can be installed from the repositories</p>
<blockquote><p>sudo apt-get install youtube-dl</p></blockquote>
<p>and then run using</p>
<blockquote><p>youtube-dl http://www.youtube.com/video_to_borrow</p></blockquote>
<p>Of course it&#8217;s up to your moral guidance to decide what you can and can&#8217;t download.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2010/01/bash-script-to-convert-flv-to-mp3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Partitions and disk space in linux</title>
		<link>http://www.stealthcopter.com/blog/2009/09/partitions-and-disk-space-in-linux/</link>
		<comments>http://www.stealthcopter.com/blog/2009/09/partitions-and-disk-space-in-linux/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 23:19:51 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=66</guid>
		<description><![CDATA[I&#8217;m sure there are many ways to see the partitions and corresponding diskspace in linux, but here is the method I found: $df -m Filesystem 1M-blocks Used Available Use% Mounted on /dev/sda2 7513 5937 1576 80% / tmpfs 1005 0 1005 0% /lib/init/rw varrun 1005 1 1005 1% /var/run varlock 1005 0 1005 0% /var/lock [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure there are many ways to see the partitions and corresponding diskspace in linux, but here is the method I found:</p>
<blockquote><p>$df -m<br />
Filesystem           1M-blocks      Used Available Use% Mounted on<br />
/dev/sda2                 7513      5937      1576  80% /<br />
tmpfs                     1005         0      1005   0% /lib/init/rw<br />
varrun                    1005         1      1005   1% /var/run<br />
varlock                   1005         0      1005   0% /var/lock<br />
udev                      1005         1      1005   1% /dev<br />
tmpfs                     1005         1      1005   1% /dev/shm<br />
/dev/sdc1               469453    353295     92311  80% /media/x<br />
/dev/sdd1              1408345    979205    429141  70% /media/z
</p></blockquote>
<p>or visually:</p>
<p><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2009/09/df.png" alt="df -m screenshot" /></p>
<p>I kept struggeling to remember what letters it was, as there are many two letter commands beginning with d in linux&#8230; (dc, dd, df, dh, do, dl, du). I now remember it, because &#8216;f&#8217; is next to the &#8216;d&#8217; key on my keyboard, and because df probably stands for disk-free. </p>
<p>For more information check out <a href="http://www.computerhope.com/unix/udf.htm">this site</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2009/09/partitions-and-disk-space-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free</title>
		<link>http://www.stealthcopter.com/blog/2009/05/free/</link>
		<comments>http://www.stealthcopter.com/blog/2009/05/free/#comments</comments>
		<pubDate>Sun, 17 May 2009 19:24:34 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=61</guid>
		<description><![CDATA[Using the free command gives output something like this (-m just tells free to output in megabytes): free -m total used free shared buffers cached Mem: 2013 1996 17 0 27 1381 -/+ buffers/cache: 588 1425 Swap: 956 0 956 This is useful but annoying as it doesn&#8217;t show you how much memory is actually [...]]]></description>
			<content:encoded><![CDATA[<p>Using the free command gives output something like this (-m just tells free to output in megabytes):</p>
<blockquote><p>
free -m<br />
             total       used       free     shared    buffers     cached<br />
Mem:          2013       1996         17          0         27       1381<br />
-/+ buffers/cache:        588       1425<br />
Swap:          956          0        956
</p></blockquote>
<p>This is useful but annoying as it doesn&#8217;t show you how much memory is actually free. Files that are used are kept in the ram (referred to as caching). If the memory is needed it is simply overwritten, however if the file is used again it is already in the memory which saves time. </p>
<p>I wrote a quick little bash line to get the actually memory in use or the actual memory free. I use grep to select the right line from the output of free, and then use awk to do the string manipulation and math.</p>
<p>Memory in use</p>
<blockquote><p>free -m | grep Mem | awk &#8216;{x=$3-$7; print x}&#8217;</p></blockquote>
<p>Memory free</p>
<blockquote><p>free -m | grep Mem | awk &#8216;{x=$2-($3-$7); print x}&#8217;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2009/05/free/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>apt &#8211; no public key error</title>
		<link>http://www.stealthcopter.com/blog/2009/05/apt-no-public-key-error/</link>
		<comments>http://www.stealthcopter.com/blog/2009/05/apt-no-public-key-error/#comments</comments>
		<pubDate>Sun, 17 May 2009 00:52:37 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=34</guid>
		<description><![CDATA[If you add a new repository to apt (/etc/apt/sources.list) you may get the following error when running &#8216;sudo apt-get update&#8217;: Reading package lists… Done W: There is no public key available for the following key IDs: [Key] W: You may want to run apt-get update to correct these problems As you probably already guessed, running [...]]]></description>
			<content:encoded><![CDATA[<p>If you add a new repository to apt (/etc/apt/sources.list) you may get the following error when running &#8216;sudo apt-get update&#8217;:</p>
<blockquote><p>
Reading package lists… Done<br />
W: There is no public key available for the following key IDs:<br />
[Key]<br />
W: You may want to run apt-get update to correct these problems
</p></blockquote>
<p>As you probably already guessed, running &#8216;sudo apt-get update&#8217; will result in exactly the same problem. This is because the new repository&#8217;s key needs to verified. This is done by the following:</p>
<blockquote><p>
gpg &#8211;keyserver subkeys.pgp.net &#8211;recv  [Key]<br />
gpg &#8211;export [Key] | sudo apt-key add -
</p></blockquote>
<p><em>replace [Key] with the key you want to add</em></p>
<p>This can also be made slightly easier by using a bash variable:</p>
<blockquote><p>
$1=[key]<br />
gpg &#8211;keyserver subkeys.pgp.net &#8211;recv  $1<br />
gpg &#8211;export $1 | sudo apt-key add -
</p></blockquote>
<p><em>replace [Key] with the key you want to add</em></p>
<p>or as a bash script:</p>
<blockquote><p>
#!/bin/sh<br />
gpg &#8211;keyserver subkeys.pgp.net &#8211;recv  $1<br />
gpg &#8211;export $1 | sudo apt-key add -</p></blockquote>
<p>ran by the following:</p>
<blockquote><p>./key [key]</p></blockquote>
<p><em>replace [Key] with the key you want to add</em><br />
which then you could place in /bin so you could simply run</p>
<p>Script can be downloaded <a href="http://www.stealthcopter.com/files/bash/key">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2009/05/apt-no-public-key-error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bash: mass image and video conversions</title>
		<link>http://www.stealthcopter.com/blog/2009/05/bash-mass-file-conversions/</link>
		<comments>http://www.stealthcopter.com/blog/2009/05/bash-mass-file-conversions/#comments</comments>
		<pubDate>Sat, 16 May 2009 01:49:58 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=4</guid>
		<description><![CDATA[Linux has many useful command line programs that will convert from one file format to another. convert &#8211; converts images (part of ImageMagick) convert input.jpg -resize 500&#215;500 output.jpg converts input.jpg to output.jpg resized to 500 by 500 pixels mencoder &#8211; converts video files mencoder -ovc lavc -oac mp3lame -o output.avi input.flv converts input.flv to output.avi [...]]]></description>
			<content:encoded><![CDATA[<p>Linux has many useful command line programs that will convert from one file format to another.</p>
<li>convert &#8211; converts images (part of <a href="http://www.imagemagick.org">ImageMagick</a>)</li>
<blockquote><p>convert input.jpg -resize 500&#215;500 output.jpg</p></blockquote>
<p><em>converts input.jpg to output.jpg resized to 500 by 500 pixels</em></p>
<li>mencoder &#8211; converts video files</li>
<blockquote><p>mencoder -ovc lavc -oac mp3lame -o output.avi input.flv</p></blockquote>
<p><em>converts input.flv to output.avi</em></p>
<p>Now lets look at some bash:</p>
<blockquote><p>for i in *.jpg; do echo $i; done</p></blockquote>
<p>This is a for loop which will assign and iterate over a variable i to every item it finds that matches *.jpg in the current directory. It will simple echo the name of the file to the console and then finish. Only really useful for testing the command works, now lets put a conversion command in instead of the echo.</p>
<blockquote><p>for i in *.jpg; do convert &#8220;$i&#8221; -resize 500&#215;500 &#8220;x_$i&#8221;; done</p></blockquote>
<p>This will take every jpg in the current directory resize it to 500 by 500 pixels and then save it as with and x_ prefixing the filename. You can get it to overwrite the current file by making the input and output file names equal (in this case it simple means removing x_ from the above code)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2009/05/bash-mass-file-conversions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
