<?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>Pario TechnoBlob &#187; rename</title>
	<atom:link href="http://pario.no/tag/rename/feed/" rel="self" type="application/rss+xml" />
	<link>http://pario.no</link>
	<description>A cronological documentation test project, nothing serious, really!</description>
	<lastBuildDate>Thu, 26 Apr 2012 08:18:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Remove white space from file names</title>
		<link>http://pario.no/2011/11/10/remove-white-space-from-file-names/</link>
		<comments>http://pario.no/2011/11/10/remove-white-space-from-file-names/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 22:10:21 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[rename]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1625</guid>
		<description><![CDATA[This is a one liner to remove white space in filenames using a linux console # rename 'y/ /_/' * You could also do this the other way, remove underscore with space # rename 'y/_//' *]]></description>
			<content:encoded><![CDATA[<p>This is a one liner to remove white space in filenames using a linux console</p>
<pre>
# rename 'y/ /_/'  *</pre>
<p>You could also do this the other way, remove underscore with space</p>
<pre>
# rename 'y/_//' *</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMTEvMTEvMTAvcmVtb3ZlLXdoaXRlLXNwYWNlLWZyb20tZmlsZS1uYW1lcy88d3B0Yj5SZW1vdmUgd2hpdGUgc3BhY2UgZnJvbSBmaWxlIG5hbWVzPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2011/11/10/remove-white-space-from-file-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rename file name suffix to uppercase or lowercase</title>
		<link>http://pario.no/2008/10/24/rename-file-name-suffix-to-uppercase-or-lowercase/</link>
		<comments>http://pario.no/2008/10/24/rename-file-name-suffix-to-uppercase-or-lowercase/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 18:12:22 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[lowercase]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[uppercase]]></category>

		<guid isPermaLink="false">http://pario.no/?p=781</guid>
		<description><![CDATA[This is a little oneliner to rename a files suffix from/to uppercase/lowercase. Rename a jpg suffix to JPG in the current folder # find -name "*.jpg" &#124; while read a; do mv "$a" "${a%%.jpg}.JPG" ; done The work JPG can be replaced by any other word :)]]></description>
			<content:encoded><![CDATA[<p>This is a little oneliner to rename a files suffix from/to uppercase/lowercase.</p>
<p>Rename a <strong>jpg</strong> suffix to <strong>JPG</strong> in the current folder</p>
<pre>
# find -name "*.jpg" | while read a; do mv "$a" "${a%%.jpg}.JPG" ; done</pre>
<p>The work JPG can be replaced by any other word :)</p>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMTAvMjQvcmVuYW1lLWZpbGUtbmFtZS1zdWZmaXgtdG8tdXBwZXJjYXNlLW9yLWxvd2VyY2FzZS88d3B0Yj5SZW5hbWUgZmlsZSBuYW1lIHN1ZmZpeCB0byB1cHBlcmNhc2Ugb3IgbG93ZXJjYXNlPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/10/24/rename-file-name-suffix-to-uppercase-or-lowercase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rename files in a folder to lower-case using perl</title>
		<link>http://pario.no/2008/10/13/rename-files-in-a-folder-to-lower-case-using-perl/</link>
		<comments>http://pario.no/2008/10/13/rename-files-in-a-folder-to-lower-case-using-perl/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 08:12:40 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[rename]]></category>

		<guid isPermaLink="false">http://pario.no/?p=751</guid>
		<description><![CDATA[This is a simple oneliner to rename files to lower-case using perl # perl -e 'rename($_, lc) &#124;&#124; warn "$_: $!\n" for @ARGV' * You can also do this recusively using find and perl # find . -type f -exec perl -e 'rename($_, lc) &#124;&#124; warn "$_: $!\n" for @ARGV' {} \;]]></description>
			<content:encoded><![CDATA[<p>This is a simple oneliner to rename files to lower-case using perl</p>
<pre>
# perl -e 'rename($_, lc) || warn "$_: $!\n" for @ARGV' *</pre>
<p>You can also do this recusively using find and perl</p>
<pre>
# find . -type f -exec perl -e 'rename($_, lc) || warn "$_: $!\n" for @ARGV' {} \;</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMTAvMTMvcmVuYW1lLWZpbGVzLWluLWEtZm9sZGVyLXRvLWxvd2VyLWNhc2UtdXNpbmctcGVybC88d3B0Yj5SZW5hbWUgZmlsZXMgaW4gYSBmb2xkZXIgdG8gbG93ZXItY2FzZSB1c2luZyBwZXJsPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/10/13/rename-files-in-a-folder-to-lower-case-using-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rename files by wildcard pattern and correct the EXIF timestamp metadata</title>
		<link>http://pario.no/2008/09/02/rename-files-by-wildcard-pattern-and-correct-the-exif-timestamp-metadata/</link>
		<comments>http://pario.no/2008/09/02/rename-files-by-wildcard-pattern-and-correct-the-exif-timestamp-metadata/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 16:05:58 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Photo etc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[EXIF]]></category>
		<category><![CDATA[exiv2]]></category>
		<category><![CDATA[jhead]]></category>
		<category><![CDATA[JPG]]></category>
		<category><![CDATA[mmv]]></category>
		<category><![CDATA[NEF]]></category>
		<category><![CDATA[Nikon]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[Sony]]></category>

		<guid isPermaLink="false">http://pario.no/?p=467</guid>
		<description><![CDATA[This is a little script I&#8217;ve written to correct all my image files since the EXIF timestamp information is one hour out of sync. The filenames have been renamed to comply to the EXIF information and has to be renamed again because of the one hour scew. The filename can look something like this 20080102-1201_DSC_0910.JPG [...]]]></description>
			<content:encoded><![CDATA[<p>This is a little script I&#8217;ve written to correct all my image files since the EXIF timestamp information is one hour out of sync. The filenames have been renamed to comply to the EXIF information and has to be renamed again because of the one hour scew. The filename can look something like this 20080102-1201_DSC_0910.JPG where the name is built up like YYYYMMDD-HHMM_Original_Filename.JPG<br />
<strong>Remember to backup your imagefiles before you continue. You have been warned!</strong></p>
<h2>Rename files using wildcard pattern</h2>
<p>This is the files we are going to rename</p>
<pre>
20080102-1201_DSC_0910.JPG
20080105-1923_DSC_1006.JPG
20080111-1220_DSC00189.JPG
20080122-0929_DSC00190.JPG</pre>
<p>The <strong>mmv</strong> command is a command that lets you move/copy/append/link multiple files by wildcard patterns. It can be installed in Debian (or Debian based distributions like Ubuntu) by issuing the command</p>
<pre>
# aptitude install mmv</pre>
<p>Now rename the files back to their original name</p>
<pre>
# mmv "*_DSC*" "DSC#2"</pre>
<p>The result after this operation looks like this</p>
<pre>
DSC_0910.JPG
DSC_1006.JPG
DSC_1179.JPG
DSC_1302.JPG
DSC_1587.JPG</pre>
<h2>Correct the EXIF timestamp using exiv2</h2>
<p>Next adjust the EXIF information stored in the image files to fix the one hour difference. This can be done using different EXIF tools like <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">exiftool</a>, but I will show you how it can be done using <a href="http://www.sentex.net/~mwandel/jhead/">jhead</a> and <a href="http://www.exiv2.org">exiv2</a>. The advantage with <strong>exiv2</strong> is that it can also handle Nikon NEF files while <strong>jhead</strong> only can prosess JPG. </p>
<p>The current timestamp can be determined as follows</p>
<pre>
# exiftool DSC_0910.JPG | grep "File Mo"</pre>
<p>The result in this case is</p>
<pre>
File Modification Date/Time : 2008:01:02 08:34:09</pre>
<h3>Adjust EXIF time info one hour forward using exiftool</h3>
<pre>
# exiftool -AllDates+=1 DSC_0910.JPG</pre>
<h3>Other tools that could have done the job</h3>
<h4>Adjust EXIF time info one hour forward using jhead</h4>
<pre>
# jhead -ta +1 DSC_0910.JPG</pre>
<p>Install the <strong>jhead</strong> package using aptitude as mentioned earlier for the mmv package</p>
<h4>Adjust EXIF time info one hour forward using exiv2</h4>
<pre>
# exiv2 ad -a 1 DSC_0910.JPG</pre>
<h2>Rename files back to YYYYMMDD-HHMM_Original_Filename.JPG</h2>
<p>It is now time to rename the files back to the YYYYMMDD-HHMM_Original_Filename.JPG format I used before this operation. This operation has been describe in a previous post named <a href="http://pario.no/2008/01/14/rename-image-files-according-to-exif-date/">Rename image files according to EXIF date</a></p>
<pre>
exiv2 -r'%Y%m%d-%H%M_:basename:' rename $(ls D*)</pre>
<h2>The script</h2>
<pre>
#!/bin/bash -x
# Needed software:
# exiftool
# exiv2
# mmv

# Script tested on Nikon D80 and Sony Cybershot DSC-W12 files

# Make a printout of how the files look like now
ls -l > repair_name_and_exif_before.txt

# Rename files to remove date formatting back to original name
mmv "*_DSC*" "DSC#2"

# Change EXIF info on JPG files (order is important)
exiftool -overwrite_original -AllDates+=1 D*.JPG
# Preserve date/time of original file when writing
exiftool -overwrite_original '-DateTimeOriginal>FileModifyDate' D*.JPG

# Change EXIF info on NEF files (order is important)
exiftool -overwrite_original -AllDates+=1 '-DateTimeOriginal>FileModifyDate' D*.NEF
# Preserve date/time of original file when writing
exiftool -overwrite_original '-DateTimeOriginal>FileModifyDate' D*.NEF

# Rename files back to date formatting (YYYYMMDD-HHMM_Filename) based on the new EXIF info
exiv2 -r'%Y%m%d-%H%M_:basename:' rename $(ls D*)

# Make a printout of how the files look like after conversion
ls -l > repair_name_and_exif_after.txt
</pre>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/www.sno.phy.queensu.ca\/~phil\/exiftool\/","http:\/\/www.sentex.net\/~mwandel\/jhead\/","http:\/\/www.exiv2.org"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMDkvMDIvcmVuYW1lLWZpbGVzLWJ5LXdpbGRjYXJkLXBhdHRlcm4tYW5kLWNvcnJlY3QtdGhlLWV4aWYtdGltZXN0YW1wLW1ldGFkYXRhLzx3cHRiPlJlbmFtZSBmaWxlcyBieSB3aWxkY2FyZCBwYXR0ZXJuIGFuZCBjb3JyZWN0IHRoZSBFWElGIHRpbWVzdGFtcCBtZXRhZGF0YTx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/09/02/rename-files-by-wildcard-pattern-and-correct-the-exif-timestamp-metadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rename file extension recursively</title>
		<link>http://pario.no/2008/02/17/rename-file-extension-recursively/</link>
		<comments>http://pario.no/2008/02/17/rename-file-extension-recursively/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 11:23:02 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[rename]]></category>

		<guid isPermaLink="false">http://pario.no/2008/02/17/rename-file-extension-recursively/</guid>
		<description><![CDATA[This is a simple bash script to rename all JPG file extensions to JPEG, it works recursively and takes subfolders also. #!/bin/bash function rename_extension { #change all .jpg to .jpeg for file in $1/*.jpg; do mv $file $1/`basename $file .jpg`.jpeg; echo $file; done; # recurse directories for d in $1/*; do if test -d $d; [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple bash script to rename all JPG file extensions to JPEG, it works recursively and takes subfolders also.</p>
<pre>
#!/bin/bash

function rename_extension
{
        #change all .jpg to .jpeg
        for file in $1/*.jpg; do
                mv $file $1/`basename $file .jpg`.jpeg;
                echo $file;
        done;

        # recurse directories
        for d in $1/*; do
                if test -d $d; then
                        rename_extension $d;
                fi;
        done;
}

dir=`pwd`;

rename_extension $dir;</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMDIvMTcvcmVuYW1lLWZpbGUtZXh0ZW5zaW9uLXJlY3Vyc2l2ZWx5Lzx3cHRiPlJlbmFtZSBmaWxlIGV4dGVuc2lvbiByZWN1cnNpdmVseTx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/02/17/rename-file-extension-recursively/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

