<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Bozica (Posts about linux)</title><link>http://bozica.co/</link><description></description><atom:link rel="self" type="application/rss+xml" href="http://bozica.co/categories/linux.xml"></atom:link><language>en</language><lastBuildDate>Mon, 26 Jun 2017 13:31:06 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Automatically sort pictures based on the date they were taken</title><link>http://bozica.co/posts/automatically-sort-pictures-based-on-the-date-they-were-taken/</link><dc:creator>Luis Ardila</dc:creator><description>&lt;div&gt;&lt;p&gt;I have been a linux user almost exclusively for at least 4 years, mainly using ubuntu. One of the things I particularly liked was the way the default tool for importing pictures (&lt;em&gt;Shotwell&lt;/em&gt;) manages the files and organize them depending on the date they were taken.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Shotwell&lt;/em&gt; will create an arrange of folders starting by the year, then the month and then the individual days, then put the corresponding pictures inside. As much as I liked this system, I always found myself wanting to organize then in a different way, where I could quickly look at a wider range of images, for example by year, but still be able to tell from the date and a short description the contents without opening the folder.&lt;/p&gt;
&lt;p&gt;My ideal organization is a folder with the year, then inside the pictures organized by day, but still in the folder name I would like the whole date before a short description I will add later. Therefore having for example &lt;em&gt;2016/2016-01-17_KA-Snow/&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Another reason why I decided to search for a script to organize my pictures is because &lt;em&gt;Shotwell&lt;/em&gt; started creating many small thumbnail files of the raw files inside the pictures folders and they were really annoying me, as much as I created another script to eliminate those thumbnails from &lt;em&gt;Shotwell&lt;/em&gt;. Also, the performance when loading pictures from the camera to import wasn't the best, most of the time taking a great amount of time just to display how many pictures were available for importing.&lt;/p&gt;
&lt;p&gt;For the previous mentioned reasons, I searched online first and found this &lt;a class="reference external" href="http://www.linuxjournal.com/content/tech-tip-automaticaly-organize-your-photos-date"&gt;code&lt;/a&gt;, which does part of the job I wanted, then I modified it and here is the code I am using now every time I connect my camera and would like to import the pictures.&lt;/p&gt;
&lt;p&gt;To notice is that I added command line options -s and -d for source and destination paths respectively, so that I could organize different folders I already have. And finally I also added the raw file extension of my camera ".RW2". I still need to include support for the video files, which I still need to copy by hand.&lt;/p&gt;
&lt;div class="section" id="sort-sh"&gt;
&lt;h2&gt;sort.sh&lt;/h2&gt;
&lt;pre class="code console"&gt;&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt;!/bin/bash
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-2"&gt;&lt;/a&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-3"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt; defaults
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-4"&gt;&lt;/a&gt;&lt;span class="go"&gt;source=/media/luisardila/5FC6-EB2A/DCIM/&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-5"&gt;&lt;/a&gt;&lt;span class="go"&gt;destination=/home/luisardila/Pictures/2016/&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-6"&gt;&lt;/a&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-7"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt; Goes through all jpeg files in &lt;span class="nb"&gt;source&lt;/span&gt; directory, grabs date from each
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-8"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt; and sorts them into destination folder in directories according to the date
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-9"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt; additionally it copies as well raw files with the same name as the jpeg
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-10"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;C&lt;span class="o"&gt;)&lt;/span&gt; Luis Ardila &lt;span class="m"&gt;2016&lt;/span&gt; &amp;lt;luis.ardila@bozica.co&amp;gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-11"&gt;&lt;/a&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-12"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt; Getting options from the commad line
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-13"&gt;&lt;/a&gt;&lt;span class="go"&gt;while getopts ":s:d:" opt; do&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-14"&gt;&lt;/a&gt;&lt;span class="go"&gt;        case $opt in&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-15"&gt;&lt;/a&gt;&lt;span class="go"&gt;        s)   # source&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-16"&gt;&lt;/a&gt;&lt;span class="go"&gt;                source=$OPTARG&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-17"&gt;&lt;/a&gt;&lt;span class="go"&gt;                ;;&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-18"&gt;&lt;/a&gt;&lt;span class="go"&gt;        d)   #destination&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-19"&gt;&lt;/a&gt;&lt;span class="go"&gt;                destination=$OPTARG&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-20"&gt;&lt;/a&gt;&lt;span class="go"&gt;                ;;&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-21"&gt;&lt;/a&gt;&lt;span class="go"&gt;        \?)&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-22"&gt;&lt;/a&gt;&lt;span class="go"&gt;                echo "Invalid option: -"$OPTARG"" &amp;gt;&amp;amp;2&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-23"&gt;&lt;/a&gt;&lt;span class="go"&gt;                exit&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-24"&gt;&lt;/a&gt;&lt;span class="go"&gt;                ;;&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-25"&gt;&lt;/a&gt;&lt;span class="go"&gt;        :)&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-26"&gt;&lt;/a&gt;&lt;span class="go"&gt;                echo "Option -"$OPTARG" requires an argument" &amp;gt;&amp;amp;2&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-27"&gt;&lt;/a&gt;&lt;span class="go"&gt;                exit&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-28"&gt;&lt;/a&gt;&lt;span class="go"&gt;                ;;&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-29"&gt;&lt;/a&gt;&lt;span class="go"&gt;        esac&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-30"&gt;&lt;/a&gt;&lt;span class="go"&gt;done&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-31"&gt;&lt;/a&gt;&lt;span class="go"&gt;i=0&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-32"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt; Executing move of files
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-33"&gt;&lt;/a&gt;&lt;span class="go"&gt;for file in $source*.jpg $source**/*.jpg $source*.JPG $source**/*.JPG # CAPS&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-34"&gt;&lt;/a&gt;&lt;span class="go"&gt;do&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-35"&gt;&lt;/a&gt;&lt;span class="go"&gt;        echo $file&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-36"&gt;&lt;/a&gt;&lt;span class="go"&gt;        if test -e "$file"; then&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-37"&gt;&lt;/a&gt;&lt;span class="go"&gt;                datepath="$(identify -verbose "${file}" | grep DateTimeOri | awk '{print $2 }' | sed s%:%-%g)"&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-38"&gt;&lt;/a&gt;&lt;span class="go"&gt;                if [[ "${datepath}" == "" ]]; then&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-39"&gt;&lt;/a&gt;&lt;span class="go"&gt;                        year="$(identify -verbose "${file}" | grep date:modify | awk '{print $2 }' | awk -F '[-]' '{print $1}')"&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-40"&gt;&lt;/a&gt;&lt;span class="go"&gt;                        datepath="${year}_Random"&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-41"&gt;&lt;/a&gt;&lt;span class="go"&gt;                fi&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-42"&gt;&lt;/a&gt;&lt;span class="go"&gt;                if ! test -e "${destination}${datepath}"; then&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-43"&gt;&lt;/a&gt;&lt;span class="go"&gt;                        mkdir -pv "${destination}${datepath}"&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-44"&gt;&lt;/a&gt;&lt;span class="go"&gt;                fi&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-45"&gt;&lt;/a&gt;&lt;span class="go"&gt;                mv -v "${file}" "${destination}${datepath}"&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-46"&gt;&lt;/a&gt;&lt;span class="go"&gt;                rawfile=$(echo ${file} | sed 's/.JPG/.RW2/g')&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-47"&gt;&lt;/a&gt;&lt;span class="go"&gt;                if test -e "$rawfile"; then&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-48"&gt;&lt;/a&gt;&lt;span class="go"&gt;                   mv -v "${rawfile}" "${destination}${datepath}"&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-49"&gt;&lt;/a&gt;&lt;span class="go"&gt;                fi&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-50"&gt;&lt;/a&gt;&lt;span class="go"&gt;        i=$(( $i + 1  ))&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-51"&gt;&lt;/a&gt;&lt;span class="go"&gt;        fi&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-52"&gt;&lt;/a&gt;&lt;span class="go"&gt;        echo "moved $i files"&lt;/span&gt;
&lt;a name="rest_code_81f1a278b306424196a269a888cd7e3b-53"&gt;&lt;/a&gt;&lt;span class="go"&gt;done&lt;/span&gt;
&lt;/pre&gt;&lt;p&gt;If you would like also to eliminate those annoying &lt;em&gt;Shotwell&lt;/em&gt; thumbnails, here is what I do:&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="rmshotwell-sh"&gt;
&lt;h2&gt;rmShotwell.sh&lt;/h2&gt;
&lt;pre class="code console"&gt;&lt;a name="rest_code_dae6093294b64a239cb16ea36e728311-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;#&lt;/span&gt;!/bin/bash
&lt;a name="rest_code_dae6093294b64a239cb16ea36e728311-2"&gt;&lt;/a&gt;
&lt;a name="rest_code_dae6093294b64a239cb16ea36e728311-3"&gt;&lt;/a&gt;&lt;span class="go"&gt;find . -name "*shotwell*" -delete&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description><category>bash</category><category>linux</category><category>ubuntu</category><guid>http://bozica.co/posts/automatically-sort-pictures-based-on-the-date-they-were-taken/</guid><pubDate>Sun, 17 Jan 2016 21:18:10 GMT</pubDate></item><item><title>Installing HandBrake to cut videos in linux</title><link>http://bozica.co/posts/installing-handbrake-to-cut-videos-in-linux/</link><dc:creator>Luis Ardila</dc:creator><description>&lt;div&gt;&lt;p&gt;Looking on the web for a quick and easy way to turn a video 90 degrees using the
terminal I found HandBrake.&lt;/p&gt;
&lt;p&gt;following &lt;a class="reference external" href="http://askubuntu.com/questions/107915/how-do-i-download-and-install-handbrake"&gt;this forum&lt;/a&gt;
this is how I installed it:&lt;/p&gt;
&lt;p&gt;there are two official HandBrake PPAs, ppa:stebbins/handbrake-releases and ppa:stebbins/handbrake-snapshots.
The former contains stable releases, which are updated about once a year.
These releases tend to be rather out-dated when their end-of-life is approaching.
The current stable version (0.9.8) was released on 2012-07-18.
The latter contains nightly builds, which are updated daily (or nightly, as it were).
These are of course less stable, and undocumented to boot, but they are good software nonetheless.
Additionally, as the stable release ages, the developers tend to start recommending users to try the nightly builds instead.&lt;/p&gt;
&lt;p&gt;To add one of these to your sources, simply run:&lt;/p&gt;
&lt;pre class="code console"&gt;&lt;a name="rest_code_c536bd9d66f64b8caaa83e32ad63a1c5-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;sudo add-apt-repository ppa:stebbins/handbrake-releases&lt;/span&gt;
&lt;/pre&gt;&lt;p&gt;or&lt;/p&gt;
&lt;pre class="code console"&gt;&lt;a name="rest_code_08a79b707881488f952e8527a5b4a190-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;sudo add-apt-repository ppa:stebbins/handbrake-snapshots&lt;/span&gt;
&lt;/pre&gt;&lt;p&gt;depending on which you want.&lt;/p&gt;
&lt;pre class="code console"&gt;&lt;a name="rest_code_87d061cb68764668b105eb385208b770-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;sudo apt-get update&lt;/span&gt;
&lt;a name="rest_code_87d061cb68764668b105eb385208b770-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;sudo apt-get install handbrake-gtk&lt;/span&gt;
&lt;/pre&gt;&lt;p&gt;Alternatively, if you would prefer the CLI over the GUI, replace the last line with:&lt;/p&gt;
&lt;pre class="code console"&gt;&lt;a name="rest_code_d517dc24f88e4ddf98103a94a4d5c303-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;apt-get install handbrake-cli&lt;/span&gt;
&lt;/pre&gt;&lt;p&gt;Now, how to rotate a video 90 degress using HandBreak?&lt;/p&gt;
&lt;pre class="code console"&gt;&lt;a name="rest_code_cba854c2ae8345d8af5fe929735762b7-1"&gt;&lt;/a&gt;&lt;span class="go"&gt;HandBrakeCLI -i /home/luisardila/Desktop/Comm/Luis.mp4 -o /home/luisardila/Desktop/Comm/Luis_90.mp4 --rotate=4&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;</description><category>handbreak</category><category>linux</category><category>video editing</category><guid>http://bozica.co/posts/installing-handbrake-to-cut-videos-in-linux/</guid><pubDate>Thu, 08 May 2014 21:47:29 GMT</pubDate></item></channel></rss>