<?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>SimpleScripts.net</title>
	<atom:link href="http://www.simplescripts.net/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.simplescripts.net</link>
	<description>Simple Scripts to Make Life Easier</description>
	<lastBuildDate>Fri, 31 Oct 2008 23:35:00 +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>FilenameUnifier</title>
		<link>http://www.simplescripts.net/?p=41</link>
		<comments>http://www.simplescripts.net/?p=41#comments</comments>
		<pubDate>Fri, 31 Oct 2008 22:49:11 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Shell Script]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=41</guid>
		<description><![CDATA[Version: v0.2 Summary: Ever wanted to mass rename a bunch of files into a specific pattern based on their original filenames? Yeah, there are other utilities out there, but this is a simple solution based on my FilenameSanitizer script which locates filenames in a given directory with a specific pattern, and then renames them based [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Version:</strong> v0.2</p>
<p><strong>Summary:</strong> Ever wanted to mass rename a bunch of files into a specific pattern based on their original filenames?  Yeah, there are other utilities out there, but this is a simple solution based on my FilenameSanitizer script which locates filenames in a given directory with a specific pattern, and then renames them based on that pattern.  As of the current version, it&#8217;s set to unify numeric .jpg images.  For example, &#8220;5466.Jpeg&#8221; would become &#8220;005466.JPG&#8221;.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>find</li>
<li>sed</li>
<li>wc</li>
<li>whoami</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/.FilenameUnifier.log&quot;</span>
<span style="color: #007800;">TMPLOG</span>=<span style="color: #ff0000;">&quot;/tmp/FilenameUnifier-<span style="color: #780078;">`whoami`</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##Write Date &amp; Time to Log File</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`date +\%B\ \%d,\ \%Y`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
&nbsp;
<span style="color: #007800;">USAGE</span>=<span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">${0}</span> -s &lt;SOURCE_DIRECTORY&gt;&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;FilenameUnifier&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Prototype by Kevin Warns&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Modified by Blake Johnson&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;http://www.simplescripts.net/&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> <span style="color: #ff0000;">'s:h'</span> OPTION; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #800000;">${OPTION}</span> <span style="color: #000000; font-weight: bold;">in</span>
		s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		h<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${USAGE}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
		\?<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unknown option <span style="color: #000099; font-weight: bold;">\&quot;</span>-<span style="color: #007800;">${OPTARG}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span><span style="color: #000000; font-weight: bold;">;;</span>
		:<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Option <span style="color: #000099; font-weight: bold;">\&quot;</span>-<span style="color: #007800;">${OPTARG}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> needs an argument.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
  			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span>
  			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
  		<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span>
  			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
  	<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SOURCE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;One or more parameters are missing.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${USAGE}</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${SOURCE}</span>&quot;</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-regextype</span> <span style="color: #ff0000;">&quot;posix-extended&quot;</span> <span style="color: #660033;">-iregex</span> <span style="color: #ff0000;">&quot;.*[/][0-9]{1,5}\.jpe?g$&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLOG}</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span> <span style="color: #666666; font-style: italic;">##Let's check for .jpg files with only numbers in their names.</span>
&nbsp;
<span style="color: #007800;">UpperBound</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLOG}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #666666; font-style: italic;">##Count the number of results found.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${UpperBound}</span>&quot;</span> = <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #666666; font-style: italic;">##Check to make sure that 'find' found some files that need to be renamed.</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;There is nothing to rename.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${UpperBound}</span> file(s) found.&quot;</span>
	<span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>
	<span style="color: #007800;">e</span>=<span style="color: #000000;">0</span>
	<span style="color: #007800;">s</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${i}</span>&quot;</span> <span style="color: #660033;">-lt</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${UpperBound}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> i += <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">TMPLINE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${i}</span>p&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLOG}</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">InputLocation</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLINE%/*}</span>&quot;</span>
		<span style="color: #007800;">InputName</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLINE##*/}</span>&quot;</span>
&nbsp;
		<span style="color: #007800;">NewName</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${InputName}</span>&quot;</span>
		<span style="color: #007800;">NewName</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${NewName}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/jpe\?g/JPG/i'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #666666; font-style: italic;">##Strip leading spaces and trailing spaces / periods.</span>
&nbsp;
		<span style="color: #007800;">FilenameLength</span>=<span style="color: #800000;">${#NewName}</span> <span style="color: #666666; font-style: italic;">##grab the # of characters in the filename</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">#number of digits = length - 4 (accounting for .jpg)</span>
		<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">COUNTER</span>=<span style="color: #007800;">$FilenameLength</span>-<span style="color: #000000;">4</span>
		<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$COUNTER</span> <span style="color: #660033;">-lt</span> <span style="color: #000000;">6</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
	   	 	<span style="color: #007800;">NewName</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #800000;">${NewName}</span>
			<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> COUNTER += <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
		<span style="color: #007800;">OutputPath</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${InputLocation}</span>/<span style="color: #007800;">${NewName}</span>&quot;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${OutputPath}</span>&quot;</span> == <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLINE}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">##Check to make sure that the name was actually changed.</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${TMPLINE}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> [ \033[1;31mNot Renamed\033[0m ]&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Reason: Name Unchanged. This may be an error in the script.&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${OutputPath}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">##Check to make sure that the new name won't overwrite an existing file.</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">OutputPath</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OutputPath}</span>.RENAME_<span style="color: #007800;">${i}</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Renaming <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${TMPLINE}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> to <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${OutputPath}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>... &quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLINE}</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${OutputPath}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mv <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${TMPLINE}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${OutputPath}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">##Check to see if the 'mv' command failed or not.</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;[ \033[1;32mRenamed\033[0m ]&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> s += <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;[ \033[1;31mNot Renamed\033[0m ]&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> e += <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
		<span style="color: #7a0874; font-weight: bold;">unset</span> NewName OutputPath TMPLINE
	<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${s}</span> / <span style="color: #007800;">${i}</span> file(s) renamed successfully.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${e}</span> file(s) could not be renamed.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLOG}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p><strong>Changes:</strong><br />
v0.2: Initial Release<br />
v0.1: Prototype</p>
<p><strong>Credits:</strong> Special thanks to Kevin Warns for creating a prototype for me to start off with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=41</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filename Sanitizer (v0.6)</title>
		<link>http://www.simplescripts.net/?p=21</link>
		<comments>http://www.simplescripts.net/?p=21#comments</comments>
		<pubDate>Fri, 18 Jul 2008 08:12:41 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Shell Script]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=21</guid>
		<description><![CDATA[Summary: This script was designed to help ease the migration of data from a Mac or Linux PC to a FAT32 flash drive, which in turn would be compatible with Windows. It does this by attempting to find any questionable characters in any of the file names, and replacing them with hyphens &#8216;-&#8217;. It also [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Summary:</strong> This script was designed to help ease the migration of data from a Mac or Linux PC to a FAT32 flash drive, which in turn would be compatible with Windows.  It does this by attempting to find any questionable characters in any of the file names, and replacing them with hyphens &#8216;-&#8217;.  It also removes leading and trailing spaces, along with trailing periods.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>find</li>
<li>sed</li>
<li>tac (coreutils)</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/.FilenameSanitizer.log&quot;</span>
<span style="color: #007800;">TMPLOG</span>=<span style="color: #ff0000;">&quot;/tmp/FilenameSanitizer-<span style="color: #780078;">`whoami`</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##Write Date &amp; Time to Log File</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`date +\%B\ \%d,\ \%Y`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
&nbsp;
<span style="color: #007800;">USAGE</span>=<span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">${0}</span> -s &lt;SOURCE_DIRECTORY&gt;&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;FilenameSanitizer&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Scripted by Blake Johnson&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;http://www.simplescripts.net/&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> <span style="color: #ff0000;">'s:h'</span> OPTION; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #800000;">${OPTION}</span> <span style="color: #000000; font-weight: bold;">in</span>
		s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">SOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		h<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${USAGE}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
		\?<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unknown option <span style="color: #000099; font-weight: bold;">\&quot;</span>-<span style="color: #007800;">${OPTARG}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span><span style="color: #000000; font-weight: bold;">;;</span>
		:<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Option <span style="color: #000099; font-weight: bold;">\&quot;</span>-<span style="color: #007800;">${OPTARG}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> needs an argument.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
  			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span>
  			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
  		<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span>
  			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
  	<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SOURCE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;One or more parameters are missing.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${USAGE}</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">##This is what the script is looking for...</span>
<span style="color: #666666; font-style: italic;">##1. Illegal Characters</span>
<span style="color: #666666; font-style: italic;">##2. Leading Spaces</span>
<span style="color: #666666; font-style: italic;">##3. Trailing Spaces and periods.</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${SOURCE}</span>&quot;</span> \
<span style="color: #660033;">-regex</span> <span style="color: #ff0000;">&quot;.*[][%\+\\<span style="color: #000099; font-weight: bold;">\&quot;</span>\*;:\?\|&lt;&gt;,=]+[^\/]*$&quot;</span> \
<span style="color: #660033;">-o</span> <span style="color: #660033;">-regex</span> <span style="color: #ff0000;">&quot;.*\/[ ]+[^\/]*$&quot;</span> \
<span style="color: #660033;">-o</span> <span style="color: #660033;">-regex</span> <span style="color: #ff0000;">&quot;.*[ .]+$&quot;</span> \
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tac</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLOG}</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span> <span style="color: #666666; font-style: italic;">##In most cases, reversing the results requires only one run of this script.</span>
&nbsp;
<span style="color: #007800;">UpperBound</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLOG}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #666666; font-style: italic;">##Count the number of results found.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${UpperBound}</span>&quot;</span> = <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #666666; font-style: italic;">##Check to make sure that 'find' found some files that need to be renamed.</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;There is nothing to rename.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${UpperBound}</span> file(s) found.&quot;</span>
	<span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>
	<span style="color: #007800;">e</span>=<span style="color: #000000;">0</span>
	<span style="color: #007800;">s</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${i}</span>&quot;</span> <span style="color: #660033;">-lt</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${UpperBound}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> i += <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">TMPLINE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${i}</span>p&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLOG}</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">InputLocation</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLINE%/*}</span>&quot;</span>
		<span style="color: #007800;">InputName</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLINE##*/}</span>&quot;</span>
&nbsp;
		<span style="color: #007800;">NewName</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${InputName}</span>&quot;</span>
		<span style="color: #007800;">NewName</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${NewName}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^ *//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ .]*$//'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #666666; font-style: italic;">##Strip leading spaces and trailing spaces / periods.</span>
		<span style="color: #007800;">NewName</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${NewName}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s/[][%\+\\<span style="color: #000099; font-weight: bold;">\&quot;</span>\*;:\?\|&lt;&gt;,=]/-/g&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #666666; font-style: italic;">##Replace illegal characters.</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${NewName}</span>&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #666666; font-style: italic;">##Check to make sure the new file name is not blank.</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">NewName</span>=<span style="color: #ff0000;">&quot;Untitled - <span style="color: #007800;">${i}</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
		<span style="color: #007800;">OutputPath</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${InputLocation}</span>/<span style="color: #007800;">${NewName}</span>&quot;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${OutputPath}</span>&quot;</span> == <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLINE}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">##Check to make sure that the name was actually changed.</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${TMPLINE}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> [ \033[1;31mNot Renamed\033[0m ]&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">exit</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${OutputPath}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">##Check to make sure that the new name won't overwrite an existing file.</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">OutputPath</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OutputPath}</span>.RENAME_<span style="color: #007800;">${i}</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Renaming <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${TMPLINE}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> to <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${OutputPath}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>... &quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLINE}</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${OutputPath}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">##Check to see if the 'mv' command failed or not.</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;[ \033[1;32mRenamed\033[0m ]&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> s += <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;[ \033[1;31mNot Renamed\033[0m ]&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> e += <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
		<span style="color: #7a0874; font-weight: bold;">unset</span> NewName OutputPath TMPLINE
	<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${s}</span> / <span style="color: #007800;">${i}</span> file(s) renamed successfully.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${e}</span> file(s) could not be renamed.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPLOG}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p><strong>Changes:</strong><br />
v0.6: Simplified the search command.  Added some more questionable characters.  Added ability to set parameters at the command line.  Displays usage line upon error.<br />
v0.5: Name changed to &#8220;Filename Sanitizer&#8221;.  Simplified the replacement of illegal characters.  Parses the results in reverse order.  Added check for duplicate names.  Commented code a bit.<br />
v0.4: Search results are now written to a file instead of variable, fixes bug with trailing spaces, removes trailing periods, removes leading and trailing spaces, counts and shows success rate.<br />
v0.3: Name changed to Filename Cleanser.  Added more questionable characters to search for.<br />
v0.2: Errors are logged, exit status of each rename command, and some other revisions.<br />
v0.1: Initial release.</p>
<p><strong>Bugs / Unimplemented Features:</strong></p>
<ul>
<li>File names with repeating periods _may_ end up disappearing off the face of the planet. (I don&#8217;t know why, or how.)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=21</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>OneStep DVD-Video (v0.3)</title>
		<link>http://www.simplescripts.net/?p=18</link>
		<comments>http://www.simplescripts.net/?p=18#comments</comments>
		<pubDate>Fri, 04 Apr 2008 07:55:56 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Script]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=18</guid>
		<description><![CDATA[Summary: A shell script to convert, and make an DVD-Video image of a specified video file. Requirements: ffmpeg dvdauthor mkisofs Code: #!/bin/bash TMP=&#34;${TMPDIR}/&#34; LOG=&#34;${HOME}/.OneStepDVDVideo.log&#34; &#160; ##Write Date &#38; Time to Log File echo &#34;-------------------------------------&#34; &#62; &#34;${LOG}&#34; echo &#34;`date +\%B\ \%d,\ \%Y`&#34; &#62;&#62; &#34;${LOG}&#34; echo &#34;-------------------------------------&#34; &#62;&#62; &#34;${LOG}&#34; &#160; echo &#34;OneStep DVD-Video&#34; echo &#34;Scripted by Blake [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Summary:</strong> A shell script to convert, and make an DVD-Video image of a specified video file.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>ffmpeg</li>
<li>dvdauthor</li>
<li>mkisofs</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">TMP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPDIR}</span>/&quot;</span>
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/.OneStepDVDVideo.log&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##Write Date &amp; Time to Log File</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`date +\%B\ \%d,\ \%Y`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;OneStep DVD-Video&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Scripted by Blake Johnson&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;http://www.simplescripts.net/&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">InputFileLocation</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${1%/*}</span>/&quot;</span>
		<span style="color: #007800;">InputFileName</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${1##*/}</span>&quot;</span>
		<span style="color: #007800;">OutputPath</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${InputFileLocation}</span><span style="color: #007800;">${InputFileName}</span>.iso&quot;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Source file either does not exist, or it is not readable.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Source not specified.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #007800;">FFmpegCommand</span>=<span style="color: #ff0000;">&quot;ffmpeg -y -i <span style="color: #007800;">${InputFileLocation}</span><span style="color: #007800;">${InputFileName}</span> -aspect 3:4 -target ntsc-dvd <span style="color: #007800;">${TMP}</span><span style="color: #007800;">${InputFileName}</span>.m2v&quot;</span>
<span style="color: #007800;">DVDAuthorStep1Command</span>=<span style="color: #ff0000;">&quot;dvdauthor -o <span style="color: #007800;">${TMP}</span><span style="color: #007800;">${InputFileName}</span>_temp/ -t <span style="color: #007800;">${TMP}</span><span style="color: #007800;">${InputFileName}</span>.m2v&quot;</span>
<span style="color: #007800;">DVDAuthorStep2Command</span>=<span style="color: #ff0000;">&quot;dvdauthor -o <span style="color: #007800;">${TMP}</span><span style="color: #007800;">${InputFileName}</span>_temp/ -T&quot;</span>
<span style="color: #007800;">MKISOFSCommand</span>=<span style="color: #ff0000;">&quot;mkisofs -dvd-video -o <span style="color: #007800;">${OutputPath}</span> <span style="color: #007800;">${TMP}</span><span style="color: #007800;">${InputFileName}</span>_temp/&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##Let's run FFmpeg</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Step 1 of 4: Converting video to a MPEG2 file...&quot;</span>
<span style="color: #007800;">FFmpegOutput</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`${FFmpegCommand} &gt; /dev/null 2&gt;&amp;1`</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">##Let's run DVDAuthor, Step1</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Step 2 of 4: Building initial DVD-Video structure...&quot;</span>
	<span style="color: #007800;">DVDAuthorStep1Output</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`${DVDAuthorStep1Command} &gt; /dev/null 2&gt;&amp;1`</span>&quot;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">##Let's run DVDAuthor, Step 2</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Step 3 of 4: Finalizing DVD-Video structure...&quot;</span>
		<span style="color: #007800;">DVDAuthorStep2Output</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`${DVDAuthorStep2Command} &gt; /dev/null 2&gt;&amp;1`</span>&quot;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">##Let's run MKISOFS.</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Step 4 of 4: Creating an ISO image of the DVD...&quot;</span>
			<span style="color: #007800;">MKISOFSOutput</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`${MKISOFSCommand} &gt; /dev/null 2&gt;&amp;1`</span>&quot;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
			<span style="color: #000000; font-weight: bold;">then</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">##Everything worked.</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;DVD-Video ISO complete.&quot;</span>
			<span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">##MKISO failed to build ISO.</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Failed to build ISO image.&quot;</span>
				<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">6</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">##DVDAuthor, Step 2 failed.</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Failed to finalize the DVD structure.&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">5</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Failed to build the initial DVD directory structure.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">4</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">##Conversion to MPEG2 failed.</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Conversion of source video to an MPEG2 file failed.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">3</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p><strong>Changes:</strong><br />
v0.3: Bug fixes and revisions.<br />
v0.2: Bug fixes and revisions.<br />
v0.1: Initial release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=18</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ServerCheck (v0.6)</title>
		<link>http://www.simplescripts.net/?p=17</link>
		<comments>http://www.simplescripts.net/?p=17#comments</comments>
		<pubDate>Sat, 08 Mar 2008 02:38:39 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Shell Script]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=17</guid>
		<description><![CDATA[Summary: This script will check to see if a web server is functioning properly by checking the output of a specific location. If this output is wrong, or unavailable, a message will be emailed. Additionally, if the server returns output which the script was not expecting, it has the ability to run a custom restore [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Summary:</strong> This script will check to see if a web server is functioning properly by checking the output of a specific location.  If this output is wrong, or unavailable, a message will be emailed.  Additionally, if the server returns output which the script was not expecting, it has the ability to run a custom restore command and hopefully get the server functioning again.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>mail</li>
<li>curl</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">##Set Default Options</span>
<span style="color: #007800;">CHECKFOR</span>=<span style="color: #ff0000;">&quot;&lt;meta name=<span style="color: #000099; font-weight: bold;">\&quot;</span>ServerCheck<span style="color: #000099; font-weight: bold;">\&quot;</span> content=<span style="color: #000099; font-weight: bold;">\&quot;</span>Success<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span> <span style="color: #666666; font-style: italic;">##This is the what the script expects to find in the result.</span>
<span style="color: #007800;">TIMEOUT</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #666666; font-style: italic;">##Max amount of time to wait for a connection.</span>
<span style="color: #007800;">MAXTIME</span>=<span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #666666; font-style: italic;">##Max time to spend trying to load page.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##Do not edit anything below this comment!</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> Restore <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Attempting Recovery...&quot;</span>
	<span style="color: #800000;">${RESTORECMD}</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Recovery successful.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Nothing is needed for <span style="color: #007800;">${CHECKURL}</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;ServerCheck&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${EMAIL}</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Recovery failed.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Manual fix may be needed for <span style="color: #007800;">${CHECKURL}</span>.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;ServerCheck&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${EMAIL}</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">USAGE</span>=<span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">${0}</span> -s &lt;WEB_ADDRESS&gt; -e &lt;EMAIL&gt; -f [CHECKFOR] -d [POST_DATA] -r [RESTORECMD]&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ServerCheck&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Scripted by Blake Johnson&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;http://www.blakeanthonyjohnson.com/&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> <span style="color: #ff0000;">':s:f:r:e:d:h'</span> OPTION; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #800000;">${OPTION}</span> <span style="color: #000000; font-weight: bold;">in</span>
		s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">CHECKURL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		f<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">CHECKFOR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		r<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">RESTORECMD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		e<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">EMAIL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		d<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">POSTDATA</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		h<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span><span style="color: #000000; font-weight: bold;">;;</span>
		\?<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unknown option <span style="color: #000099; font-weight: bold;">\&quot;</span>-<span style="color: #007800;">${OPTARG}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span><span style="color: #000000; font-weight: bold;">;;</span>
		:<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Option <span style="color: #000099; font-weight: bold;">\&quot;</span>-<span style="color: #007800;">${OPTARG}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> needs an argument.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
  			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span>
  			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
  		<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span>
  			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
  	<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CHECKURL</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;One or more parameters are missing.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${USAGE}</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$EMAIL</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;One or more parameters are missing.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${USAGE}</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Checking URL:  <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${CHECKURL}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Email: <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${EMAIL}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Checking for: <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">${CHECKFOR}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Checking if server is working properly... &quot;</span>
&nbsp;
<span style="color: #007800;">CURLCOMMAND</span>=<span style="color: #ff0000;">&quot;curl -s <span style="color: #007800;">${CHECKURL}</span> --connect-timeout <span style="color: #007800;">${TIMEOUT}</span> --max-time <span style="color: #007800;">${MAXTIME}</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$POSTDATA</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">CURLCOMMAND</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${CURLCOMMAND}</span> -d <span style="color: #007800;">${POSTDATA}</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">CURLOUTPUT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #800000;">${CURLCOMMAND}</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CURLOUTPUT</span>&quot;</span> =~ <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CHECKFOR</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;String not found.&quot;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$RESTORECMD</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			Restore	
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Wrong output recieved.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Please check <span style="color: #007800;">${CHECKURL}</span>.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;ServerCheck&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${EMAIL}</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Some other error occurred.&quot;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$RESTORECMD</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		Restore
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Server may be down.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Please check <span style="color: #007800;">${CHECKURL}</span>.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;ServerCheck&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${EMAIL}</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;This script will self-destruct in 6 seconds.&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">6</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p><strong>Note:</strong> Mac OS X users may have to change the line endings to the Unix equivalent.</p>
<p><strong>Changes:</strong><br />
v0.6: Adds the ability to run a custom restore command.<br />
v0.5: Adds the ability to add post data to a page request.<br />
v0.3: Restructured how the parameters are read in.<br />
v0.2: Allowed parameters to be set at the command line.<br />
v0.1: Initial release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=17</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gnome Background Rotator</title>
		<link>http://www.simplescripts.net/?p=15</link>
		<comments>http://www.simplescripts.net/?p=15#comments</comments>
		<pubDate>Fri, 15 Feb 2008 06:17:49 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Gnome]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Script]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=15</guid>
		<description><![CDATA[Version: v0.5 Summary: This is an easy way to make your desktop rotate images. All you need to do is specify a background location, and it will find all the *.jpg, *.png, and *.svg files in that folder and display them in a random order. Requirements: Gnome find sed wc whoami Code: #!/bin/bash &#160; #User [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Version:</strong> v0.5</p>
<p><strong>Summary:</strong> This is an easy way to make your desktop rotate images.  All you need to do is specify a background location, and it will find all the *.jpg, *.png, and *.svg files in that folder and display them in a random order.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>Gnome</li>
<li>find</li>
<li>sed</li>
<li>wc</li>
<li>whoami</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#User Settable Variables (Defaults)</span>
<span style="color: #007800;">BACKGROUND_PATH</span>=<span style="color: #ff0000;">&quot;/usr/share/.backgrounds/&quot;</span>
<span style="color: #007800;">BACKGROUND_STYLE</span>=<span style="color: #ff0000;">&quot;zoom&quot;</span> <span style="color: #666666; font-style: italic;">## 'zoom', 'tiled', 'scaled', 'stretched', 'centered'</span>
<span style="color: #007800;">CYCLE_TIME</span>=<span style="color: #ff0000;">&quot;7&quot;</span>
<span style="color: #007800;">TEMP_LOG</span>=<span style="color: #ff0000;">&quot;/tmp/rotate<span style="color: #007800;">${RANDOM}</span>.log&quot;</span>
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;/tmp/.<span style="color: #780078;">`whoami`</span>-gnome-background-rotator&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##Write Date &amp; Time to Log File</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`date +\%B\ \%d,\ \%Y`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG}</span>&quot;</span>
&nbsp;
<span style="color: #007800;">USAGE</span>=<span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">${0}</span> -p &lt;SOURCE_DIRECTORY&gt; -t &lt;CYCLE_TIME&gt; -k &lt;KEYWORD&gt;&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Gnome Background Rotator&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Scripted by Blake Johnson&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;http://www.simplescripts.net/&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> <span style="color: #ff0000;">':p:k:t:h'</span> OPTION; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #800000;">${OPTION}</span> <span style="color: #000000; font-weight: bold;">in</span>
		p<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">BGPATH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		k<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">KEYWORD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		t<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">CTIME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${OPTARG}</span>&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
		h<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${USAGE}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
		\?<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unknown option <span style="color: #000099; font-weight: bold;">\&quot;</span>-<span style="color: #007800;">${OPTARG}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span><span style="color: #000000; font-weight: bold;">;;</span>
		:<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Option <span style="color: #000099; font-weight: bold;">\&quot;</span>-<span style="color: #007800;">${OPTARG}</span><span style="color: #000099; font-weight: bold;">\&quot;</span> needs an argument.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
  			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span>
  			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
  		<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${USAGE}</span>
  			<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">;;</span>
  	<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BGPATH</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#Check to see if another background source was given.</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BGPATH</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">BACKGROUND_PATH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${BGPATH}</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unable to continue.  Source specified is not a (readable) directory.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CTIME</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#Check to see if another cycle time was given.</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CTIME</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">CYCLE_TIME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${CTIME}</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unable to continue.  Time given is not a valid number.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
gconftool-<span style="color: #000000;">2</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">--type</span>=string <span style="color: #000000; font-weight: bold;">/</span>desktop<span style="color: #000000; font-weight: bold;">/</span>gnome<span style="color: #000000; font-weight: bold;">/</span>background<span style="color: #000000; font-weight: bold;">/</span>picture_options <span style="color: #800000;">${BACKGROUND_STYLE}</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Search for images and create a temporary logfile of all matches</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$KEYWORD</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #800000;">${BACKGROUND_PATH}</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;*<span style="color: #007800;">${KEYWORD}</span>*.jpg&quot;</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;*<span style="color: #007800;">${KEYWORD}</span>*.png&quot;</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;*<span style="color: #007800;">${KEYWORD}</span>*.svg&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${TEMP_LOG}</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #800000;">${BACKGROUND_PATH}</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;*.jpg&quot;</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;*.png&quot;</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;*.svg&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${TEMP_LOG}</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">LowerBound</span>=<span style="color: #000000;">1</span>
<span style="color: #007800;">RandomMax</span>=<span style="color: #000000;">32767</span>
<span style="color: #007800;">UpperBound</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${TEMP_LOG}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$UpperBound</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#Check to make sure 1 or more results have been returned.</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting to rotate through <span style="color: #007800;">${UpperBound}</span> images(s).&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;No images found.  Please change directories, or try another keyword.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #666666; font-style: italic;"># Choose a random line number (any number from 1 to the length of the file)</span>
		<span style="color: #007800;">RandomLine</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #800000;">${LowerBound}</span> + <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #800000;">${UpperBound}</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #800000;">${RANDOM}</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #800000;">${RandomMax}</span> + <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;"># Use sed to grab the random line</span>
		<span style="color: #007800;">IMAGE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$RandomLine</span>{p;q;}&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TEMP_LOG}</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$IMAGE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
		<span style="color: #000000; font-weight: bold;">then</span>	
        		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Changing background to: <span style="color: #007800;">${IMAGE}</span>&quot;</span>
        		gconftool-<span style="color: #000000;">2</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">--type</span>=string <span style="color: #000000; font-weight: bold;">/</span>desktop<span style="color: #000000; font-weight: bold;">/</span>gnome<span style="color: #000000; font-weight: bold;">/</span>background<span style="color: #000000; font-weight: bold;">/</span>picture_filename <span style="color: #ff0000;">&quot;<span style="color: #007800;">${IMAGE}</span>&quot;</span>
        		<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #800000;">${CYCLE_TIME}</span>
        	<span style="color: #000000; font-weight: bold;">else</span>
        		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unable to change the background to: <span style="color: #007800;">${IMAGE}</span>&quot;</span>
        		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The background either does not exist anymore, or the permissions to it are denied.&quot;</span>
        	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p><strong>Changes:</strong><br />
v0.5: Ability to adjust cycle-time and background directory at command line, and also specify a background keyword.  More checks added to make sure everything works as expected.<br />
v0.4: Minor fixes.<br />
v0.3: Backgrounds are now randomized.<br />
v0.2: Minor fixes.<br />
v0.1: Initial release.</p>
<p><strong>Credits:</strong> Special thanks to Kevin Warns for implementing the randomization feature.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=15</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FirefoxUpdater (v0.2)</title>
		<link>http://www.simplescripts.net/?p=13</link>
		<comments>http://www.simplescripts.net/?p=13#comments</comments>
		<pubDate>Sat, 05 Jan 2008 02:39:21 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Script]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=13</guid>
		<description><![CDATA[Summary: Want an easy way to update Firefox to the latest (nightly) build? Want it to automatically update itself? Set this script as a cron job to run nightly, and all that will be taken care of. This can also be used as a way of pushing out Firefox to other computers. Requirements: Firefox wget [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Summary:</strong> Want an easy way to update Firefox to the latest (nightly) build?  Want it to automatically update itself?  Set this script as a cron job to run nightly, and all that will be taken care of.  This can also be used as a way of pushing out Firefox to other computers.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>Firefox</li>
<li>wget</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">MARDIRURL</span>=<span style="color: #ff0000;">&quot;http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk&quot;</span>
<span style="color: #007800;">MARFILENAME</span>=<span style="color: #ff0000;">&quot;firefox-3.0b3pre.en-US.linux-i686.complete.mar&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${MARDIRURL}</span>/<span style="color: #007800;">${MARFILENAME}</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${MARFILENAME}</span>&quot;</span> <span style="color: #ff0000;">&quot;/usr/lib/firefox-updater/update.mar&quot;</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;/usr/lib/firefox/&quot;</span>
..<span style="color: #000000; font-weight: bold;">/</span>firefox-updater<span style="color: #000000; font-weight: bold;">/</span>updater ..<span style="color: #000000; font-weight: bold;">/</span>firefox-updater <span style="color: #000000;">0</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #ff0000;">&quot;/usr/lib/firefox-updater/update.mar&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rockbox Updater (v0.2)</title>
		<link>http://www.simplescripts.net/?p=10</link>
		<comments>http://www.simplescripts.net/?p=10#comments</comments>
		<pubDate>Wed, 02 Jan 2008 01:50:28 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Script]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=10</guid>
		<description><![CDATA[Summary: Use this simple shell script to update the build of Rockbox on your DAP. Just change the variables at the top, and you should be good to go. Requirements: Linux wget unzip Code: #!/bin/bash RBMOUNTPOINT=&#34;/media/IHP-100&#34; RBZIPURL=&#34;http://build.rockbox.org/dist/build-h300/rockbox.zip&#34; ##Filename must be rockbox.zip. cd &#34;${TMPDIR}&#34; wget &#34;${RBZIPURL}&#34; cd &#34;${RBMOUNTPOINT}/&#34; unzip -o &#34;${TMPDIR}/rockbox.zip&#34; rm &#34;${TMPDIR}/rockbox.zip&#34;]]></description>
			<content:encoded><![CDATA[<p><strong>Summary:</strong> Use this simple shell script to update the build of Rockbox on your <acronym title="Digital Audio Player">DAP</acronym>.  Just change the variables at the top, and you should be good to go.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>Linux</li>
<li>wget</li>
<li>unzip</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">RBMOUNTPOINT</span>=<span style="color: #ff0000;">&quot;/media/IHP-100&quot;</span>
<span style="color: #007800;">RBZIPURL</span>=<span style="color: #ff0000;">&quot;http://build.rockbox.org/dist/build-h300/rockbox.zip&quot;</span>  <span style="color: #666666; font-style: italic;">##Filename must be rockbox.zip.</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPDIR}</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${RBZIPURL}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${RBMOUNTPOINT}</span>/&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">unzip</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPDIR}</span>/rockbox.zip&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TMPDIR}</span>/rockbox.zip&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix Hosts File (v1.0)</title>
		<link>http://www.simplescripts.net/?p=9</link>
		<comments>http://www.simplescripts.net/?p=9#comments</comments>
		<pubDate>Mon, 31 Dec 2007 23:12:20 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Batch File]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=9</guid>
		<description><![CDATA[Summary: This batch file will make it a bit easier to fix your ‘hosts’ file. Requirements: Windows 2000 / XP / Vista Code: @echo off cls echo Fix the Host File echo By Blake Johnson echo http://www.blakeanthonyjohnson.com echo. echo. echo Are you blocked from a specific web site? Find the domain name and echo if [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Summary:</strong> This batch file will make it a bit easier to fix your ‘hosts’ file.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>Windows 2000 / XP / Vista</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;"><span style="color: #66cc66;">@</span>echo <span style="color: #0080FF; font-weight: bold;">off</span>
cls
echo Fix the Host File
echo <span style="color: #800080;">By</span> Blake Johnson
echo <span style="color: #0080FF; font-weight: bold;">http</span><span style="color: #FF1010; font-weight: bold;">://www.blakeanthonyjohnson.com</span>
echo.
echo.
echo Are you blocked from a specific web site<span style="color: #66cc66;">?</span>  Find the domain name and
echo <span style="color: #800080;">if</span> it is <span style="color: #800080;">in</span> the list, remove it.  Problem should <span style="color: #800080;">then</span> be solved.
echo. 
<span style="color: #0000FF;">pause</span>
echo.
echo Remove Read<span style="color: #66cc66;">-</span>only and System attributes from the Hosts file...
attrib <span style="color: #66cc66;">-</span>s <span style="color: #66cc66;">-</span>r <span style="color: #66cc66;">%</span>windir<span style="color: #66cc66;">%</span>\system32\drivers\etc\hosts
echo Done.
echo.
echo <span style="color: #0080FF; font-weight: bold;">Open</span> the Hosts file <span style="color: #800080;">for</span> editing...
notepad <span style="color: #66cc66;">%</span>windir<span style="color: #66cc66;">%</span>\system32\drivers\etc\hosts
echo Done.
echo.
echo Apply the Read<span style="color: #66cc66;">-</span>only and System attributes <span style="color: #800080;">to</span> the Hosts file...
attrib <span style="color: #66cc66;">+</span>s <span style="color: #66cc66;">+</span>r <span style="color: #66cc66;">%</span>windir<span style="color: #66cc66;">%</span>\system32\drivers\etc\hosts
echo Done.
echo.
echo.
echo Assuming you made the changes you intended <span style="color: #800080;">to</span> make, you should
echo be good <span style="color: #800080;">to</span> go.
echo.
<span style="color: #0000FF;">pause</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=9</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup2Novell (v2.0)</title>
		<link>http://www.simplescripts.net/?p=8</link>
		<comments>http://www.simplescripts.net/?p=8#comments</comments>
		<pubDate>Mon, 31 Dec 2007 22:25:33 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Script]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=8</guid>
		<description><![CDATA[Summary: Backup2Novell automates the process of archiving a folder or file, and then adding it to a specific folder on a Novell server. It uses 7zip for Unix for it&#8217;s archives. Requirements: ncpfs p7zip Code: #!/bin/bash &#160; ##By Blake Johnson &#160; USERNAME=&#34;USERNAME&#34; ##Novell Username (this is case sensative to whatever the mounted directory will use.) [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Summary:</strong> Backup2Novell automates the process of archiving a folder or file, and then adding it to a specific folder on a Novell server.  It uses 7zip for Unix for it&#8217;s archives.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>ncpfs</li>
<li>p7zip</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##By Blake Johnson</span>
&nbsp;
<span style="color: #007800;">USERNAME</span>=<span style="color: #ff0000;">&quot;USERNAME&quot;</span> <span style="color: #666666; font-style: italic;">##Novell Username (this is case sensative to whatever the mounted directory will use.)</span>
<span style="color: #007800;">CONTEXT</span>=<span style="color: #ff0000;">&quot;something.something&quot;</span> <span style="color: #666666; font-style: italic;">##Novell Context w/ out beginning dot.</span>
<span style="color: #007800;">PASSWORD</span>=<span style="color: #ff0000;">&quot;PASSWORD&quot;</span> <span style="color: #666666; font-style: italic;">##Novell Password</span>
&nbsp;
<span style="color: #007800;">BACKUPNAME</span>=<span style="color: #ff0000;">&quot;public_html&quot;</span> <span style="color: #666666; font-style: italic;">##This must not contain any special characters.</span>
<span style="color: #007800;">BACKUPSOURCE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/public_html/&quot;</span> <span style="color: #666666; font-style: italic;">##What file or folder would you like to back up?</span>
&nbsp;
<span style="color: #007800;">SERVERNAME</span>=<span style="color: #ff0000;">&quot;SERVERNAME&quot;</span> <span style="color: #666666; font-style: italic;">##The name of the remote Novell server.</span>
<span style="color: #007800;">SERVERADDRESS</span>=<span style="color: #ff0000;">&quot;SERVERIP&quot;</span> <span style="color: #666666; font-style: italic;">##The address of the remote Novell server.</span>
&nbsp;
<span style="color: #007800;">MOUNTDIRECTORY</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/mnt/MOUNTPOINT&quot;</span> <span style="color: #666666; font-style: italic;">##The directory where you want to mount the Novell share.</span>
&nbsp;
<span style="color: #007800;">BACKUPHOME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${MOUNTDIRECTORY}</span>/STAFF/USERS/Folders/<span style="color: #007800;">${USERNAME}</span>&quot;</span> <span style="color: #666666; font-style: italic;">##Directory where you are first able to write.</span>
<span style="color: #007800;">BACKUPFILENAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${BACKUPNAME}</span>.<span style="color: #780078;">`date +\%Y\%m\%d`</span>.7z&quot;</span> <span style="color: #666666; font-style: italic;">##This must not contain any special characters.</span>
<span style="color: #007800;">BACKUPDESTINATION</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${MOUNTDIRECTORY}</span>/Folders/<span style="color: #007800;">${USERNAME}</span>/.backup/<span style="color: #007800;">${BACKUPNAME}</span>&quot;</span> <span style="color: #666666; font-style: italic;">##Where should the backup file be placed?</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##Write Date &amp; Time to Log File</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`date +\%B\ \%d,\ \%Y`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-------------------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Checking if the ncpfs package is installed... &quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ncpmount <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">##Log in to Novell Share and mount it.</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Mounting Novell Share... &quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ncpmount -S <span style="color: #007800;">${SERVERNAME}</span> -A <span style="color: #007800;">${SERVERADDRESS}</span> -U <span style="color: #007800;">${USERNAME}</span>.<span style="color: #007800;">${CONTEXT}</span> -P <span style="color: #007800;">${PASSWORD}</span> <span style="color: #007800;">${MOUNTDIRECTORY}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
	ncpmount <span style="color: #660033;">-S</span> <span style="color: #800000;">${SERVERNAME}</span> <span style="color: #660033;">-A</span> <span style="color: #800000;">${SERVERADDRESS}</span> <span style="color: #660033;">-U</span> <span style="color: #800000;">${USERNAME}</span>.<span style="color: #800000;">${CONTEXT}</span> <span style="color: #660033;">-P</span> <span style="color: #800000;">${PASSWORD}</span> <span style="color: #800000;">${MOUNTDIRECTORY}</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
&nbsp;
	<span style="color: #666666; font-style: italic;">##Check to see if userfolder exists.</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #800000;">${BACKUPHOME}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backing up <span style="color: #007800;">${BACKUPSOURCE}</span>&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Please Wait...&quot;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">##Compress and archive backup source and send it to the Novell Folder.</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;7z a &quot;</span><span style="color: #800000;">${BACKUPDESTINATION}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${BACKUPFILENAME}</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #800000;">${BACKUPSOURCE}</span><span style="color: #ff0000;">&quot; &gt;&gt; <span style="color: #007800;">${HOME}</span>/.Backup2Novell.log&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span>  <span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
		7z a <span style="color: #ff0000;">&quot;<span style="color: #007800;">${BACKUPDESTINATION}</span>/<span style="color: #007800;">${BACKUPFILENAME}</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${BACKUPSOURCE}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
&nbsp;
		<span style="color: #666666; font-style: italic;">##Check to see if the file was written.</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${BACKUPDESTINATION}</span>/<span style="color: #007800;">${BACKUPFILENAME}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;~/public_html Backup \033[1;32mSuccessful&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;~/public_html Backup \033[1;31mFailed&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0mUnable to write to destination&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">##Unmount and log out of the Novell share.</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Unmounting Novell Share... &quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ncpumount <span style="color: #007800;">${MOUNTDIRECTORY}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
		ncpumount <span style="color: #800000;">${MOUNTDIRECTORY}</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>.Backup2Novell.log
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #800000;">${BACKUPHOME}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;32mOK!&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed!&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0m&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[1;31mFailed.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\033[0mYou must install the ncpfs package in order for this script to work.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;This script will self-destruct in 5 seconds.&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> 5s</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=8</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WavPack Frontend (v0.8)</title>
		<link>http://www.simplescripts.net/?p=7</link>
		<comments>http://www.simplescripts.net/?p=7#comments</comments>
		<pubDate>Mon, 31 Dec 2007 08:25:52 +0000</pubDate>
		<dc:creator>Blake Johnson</dc:creator>
				<category><![CDATA[Batch File]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.simplescripts.net/?p=7</guid>
		<description><![CDATA[Summary: Tired of using the command line switches to convert a song to the Wavpack format? This will make your life a bit easier. Requirements: WavPack *.wav file Code: @echo off &#160; :: ::Set wavpackexe to the path of the WavPack exe on your system. :: &#160; set wavpackexe=&#34;C:\Program Files\WavPack\wavpack.exe&#34; &#160; :: ::Other Variables :: [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Summary:</strong>  Tired of using the command line switches to convert a song to the Wavpack format?  This will make your life a bit easier.</p>
<p><strong>Requirements:</strong> </p>
<ul>
<li><a href="http://www.wavpack.com/">WavPack</a></li>
<li>*.wav file</li>
</ul>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;"><span style="color: #66cc66;">@</span>echo <span style="color: #0080FF; font-weight: bold;">off</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">::</span>
<span style="color: #FF1010; font-weight: bold;">::Set wavpackexe to the path of the WavPack exe on your system.</span>
<span style="color: #FF1010; font-weight: bold;">::</span>
&nbsp;
set wavpackexe=<span style="color: #ff0000;">&quot;C:\Program Files\WavPack\wavpack.exe&quot;</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">::</span>
<span style="color: #FF1010; font-weight: bold;">::Other Variables</span>
<span style="color: #FF1010; font-weight: bold;">::</span>
&nbsp;
set target= 
&nbsp;
&nbsp;
echo <span style="color: #66cc66;">-------------------------</span>
echo   WavPack Frontend v0.8
echo <span style="color: #66cc66;">-------------------------</span>
echo     <span style="color: #800080;">By</span> Blake Johnson
&nbsp;
<span style="color: #800080;">if</span> exist <span style="color: #66cc66;">%</span>2 <span style="color: #800080;">goto</span> alert2files
<span style="color: #800080;">if</span> exist <span style="color: #66cc66;">%</span>1 <span style="color: #800080;">goto</span> pass2
<span style="color: #800080;">goto</span> pass1
&nbsp;
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:pass1</span>
echo.
echo.
echo First of all, where is your file located<span style="color: #66cc66;">?</span>
echo <span style="color: #66cc66;">&#40;</span>Feel free <span style="color: #800080;">to</span> drag and <span style="color: #800080;">drop</span> it <span style="color: #800080;">in</span> this box.<span style="color: #66cc66;">&#41;</span>
echo.
Set <span style="color: #66cc66;">/</span>p source=Location of file<span style="color: #FF1010; font-weight: bold;">:</span>
cls
<span style="color: #800080;">goto</span> menu
&nbsp;
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:alert2files</span>
echo.
echo.
echo You have selected more than one file, only one file will be used.
echo File being used<span style="color: #FF1010; font-weight: bold;">: %1</span>
<span style="color: #800080;">goto</span> pass2
&nbsp;
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:pass2</span>
echo.
echo.
set source=<span style="color: #66cc66;">%</span>1
<span style="color: #800080;">goto</span> menu
&nbsp;
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:menu</span>
echo.
echo.
echo Here are some more options.
echo.
echo 1. Choose other destination.
echo 2. Tag the file.
echo 3. Convert <span style="color: #800080;">to</span> WavPack.
echo.
echo 4. <span style="color: #800080;">Exit</span>.
&nbsp;
set <span style="color: #66cc66;">/</span>p option=What option do you want<span style="color: #66cc66;">?</span> 
&nbsp;
cls
&nbsp;
<span style="color: #800080;">if</span> <span style="color: #ff0000;">&quot;%option%&quot;</span>==<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #800080;">goto</span> cngtarget
<span style="color: #800080;">if</span> <span style="color: #ff0000;">&quot;%option%&quot;</span>==<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #800080;">goto</span> tag
<span style="color: #800080;">if</span> <span style="color: #ff0000;">&quot;%option%&quot;</span>==<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #800080;">goto</span> convert2wv
<span style="color: #800080;">if</span> <span style="color: #ff0000;">&quot;%option%&quot;</span>==<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #800080;">goto</span> <span style="color: #800080;">exit</span>
&nbsp;
cls
echo <span style="color: #66cc66;">%</span>option<span style="color: #66cc66;">%</span>
echo.
echo. You did not choose a valid option.
echo. Please try again.
<span style="color: #800080;">goto</span> menu
&nbsp;
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:cngtarget</span>
echo.
echo.
echo Choose a new destination. <span style="color: #66cc66;">&#40;</span>Physical path <span style="color: #800080;">to</span> file only.<span style="color: #66cc66;">&#41;</span>
echo USE QUOTES<span style="color: #66cc66;">!!!</span>
echo.
echo <span style="color: #800080;">To</span> <span style="color: #0080FF; font-weight: bold;">cancel</span>, just press enter.
echo.
echo.
set <span style="color: #66cc66;">/</span>p target=Destination<span style="color: #FF1010; font-weight: bold;">:</span>
cls
<span style="color: #800080;">goto</span> menu
&nbsp;
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:tag</span>
echo.
echo.
echo Enter the following information <span style="color: #800080;">for</span> tagging.
echo <span style="color: #800080;">If</span> you leave one blank, it will not exist as a tag.
echo.
set <span style="color: #66cc66;">/</span>p artist=Artist<span style="color: #FF1010; font-weight: bold;">:</span>
set <span style="color: #66cc66;">/</span>p title=Title<span style="color: #FF1010; font-weight: bold;">:</span>
set <span style="color: #66cc66;">/</span>p album=Album<span style="color: #FF1010; font-weight: bold;">:</span>
set <span style="color: #66cc66;">/</span>p year=Year<span style="color: #FF1010; font-weight: bold;">:</span>
set <span style="color: #66cc66;">/</span>p track=Track <span style="color: #66cc66;">#</span><span style="color: #FF1010; font-weight: bold;">:</span>
set <span style="color: #66cc66;">/</span>p genre=Genre<span style="color: #FF1010; font-weight: bold;">:</span>
echo.
echo.
echo <span style="color: #800080;">If</span> the following is not correct, <span style="color: #800080;">exit</span> the batch file and try again.
echo.
<span style="color: #800080;">if</span> not <span style="color: #ff0000;">&quot;%artist%&quot;</span>==<span style="color: #ff0000;">&quot;&quot;</span> echo Artist<span style="color: #FF1010; font-weight: bold;">: %artist%</span>
<span style="color: #800080;">if</span> not <span style="color: #ff0000;">&quot;%title%&quot;</span>==<span style="color: #ff0000;">&quot;&quot;</span> echo Title<span style="color: #FF1010; font-weight: bold;">: %title%</span>
<span style="color: #800080;">if</span> not <span style="color: #ff0000;">&quot;%album%&quot;</span>==<span style="color: #ff0000;">&quot;&quot;</span> echo Album<span style="color: #FF1010; font-weight: bold;">: %album%</span>
<span style="color: #800080;">if</span> not <span style="color: #ff0000;">&quot;%year%&quot;</span>==<span style="color: #ff0000;">&quot;&quot;</span> echo Year<span style="color: #FF1010; font-weight: bold;">: %year%</span>
<span style="color: #800080;">if</span> not <span style="color: #ff0000;">&quot;%track%&quot;</span>==<span style="color: #ff0000;">&quot;&quot;</span> echo Track<span style="color: #FF1010; font-weight: bold;">: %track%</span>
<span style="color: #800080;">if</span> not <span style="color: #ff0000;">&quot;%genre%&quot;</span>==<span style="color: #ff0000;">&quot;&quot;</span> echo Genre<span style="color: #FF1010; font-weight: bold;">: %genre%</span>
echo.
echo.
<span style="color: #0000FF;">pause</span>
cls
<span style="color: #800080;">goto</span> menu
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:convert2wv</span>
echo.
echo.
<span style="color: #66cc66;">%</span>wavpackexe<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>w <span style="color: #ff0000;">&quot;Artist=%artist%&quot;</span> <span style="color: #66cc66;">-</span>w <span style="color: #ff0000;">&quot;Title=%title%&quot;</span> <span style="color: #66cc66;">-</span>w <span style="color: #ff0000;">&quot;Album=%album%&quot;</span> <span style="color: #66cc66;">-</span>w <span style="color: #ff0000;">&quot;Year=%year%&quot;</span> <span style="color: #66cc66;">-</span>w <span style="color: #ff0000;">&quot;Track=%track%&quot;</span> <span style="color: #66cc66;">-</span>w <span style="color: #ff0000;">&quot;Genre=%genre%&quot;</span> <span style="color: #66cc66;">-</span>h <span style="color: #66cc66;">%</span>source<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">%</span>target<span style="color: #66cc66;">%</span>
&nbsp;
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:exit</span>
<span style="color: #800080;">exit</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.simplescripts.net/?feed=rss2&amp;p=7</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
