Linux

Backup your Pictures in Linux Mint – Ubuntu

This script takes all the jpg pictures inside the PICSSOURCE folder and backs them up into the PICSDESTINATION folder. The script reads the creation date of the pictures and based on that it creates folders with the year  and month (ie. 2014-08) to where the pictures are stored. Pictures without date information are copied into the “No-date” folder.

Download script

#!/bin/bash

# Backup your pictures
# By Juan C. Riano

# This script backups your JPG or JPEG pictures organizing them into folders by year and month.
# Folders are created only if they do not already exist.

# Dependencies: grep, awk, exif.

# Destination folder.
PICSDESTINATION='/home/juan/Pictures/'

# Source Folder
PICSSOURCE=~/Dropbox/pics

for file in $( ls $PICSSOURCE/*.{jpg,JPG,JPEG,jpeg} )
do 
	echo "Backing up $file"
	WHOLESTR=$( exif $file | grep 'Date and Time' | grep 'Origi' )
	THEDATE=$( echo "$WHOLESTR" | awk '{split($0,arr,"|"); print arr[2]}' )
	THEYEAR=$( echo "$THEDATE" | awk '{split($0,arr,":"); print arr[1]}' )
	THEMONTH=$( echo "$THEDATE" | awk '{split($0,arr,":"); print arr[2]}' )

	if [[ "$THEYEAR" == "" ]]	# Is there exif info for this picture?
	then
		THEFOLDER="$PICSDESTINATION/no-date"	# Pictures with no exif info.
	else 
		THEFOLDER="$PICSDESTINATION/$THEYEAR-$THEMONTH"	# Folder in format yyyy-mm
	fi
	
	# Create folder, ignore if folder already exists.
	$( mkdir -p "$THEFOLDER")

	# Copy files, change for mv if you want to delete original files.
	cp "$file" "$THEFOLDER"
done
echo "Completed backing up pictures."

If you rather delete the pictures, just changed the “cp” command for “mv”.

Use Dropbox and This Script to Backup your Cellphone Pictures

You can configure Dropbox to automatically backup your cellphone pictures to a folder in your Dropbox, then run this script to backup your pictures organized by date from your computer to an external hard drive.

Convert many pictures into a single pdf in Linux Mint / Ubuntu

If you take pictures of your lectures in school, this is an easy way to put them together into a single document that will contain all the pictures sorted by name. This works for any Linux distribution, only the way you install the programs may change.

First, you will need to install two applications:

sudo apt-get install ImageMagic pdfmod

Now go into the folder where you have your pictures – you should have nothing but pictures! – then run the following command:

convert -quality 90 * pictures.pdf 

Sometimes the resulting pdf document has pictures with the wrong orientation, you can fix that by running:

pdfmod pictures.pdf

Of course save the document after making the changes.

Cleanup File Names

This is a simple bash script meant to clean the names of your songs or pictures. Just drop the script in a folder containing (only) your target files, and run it. It will change the names of anything apart from the script.

Download script.

#!/bin/bash

# By Juan Riaño
# juanriano.com

# Feel free to use as you please, a thank you card (or email) will be appreciated,
# but don't hold me responsible for whacking your grandma's pc.

# This script standardizes file names, it is meant mostly for mp3s or pictures, just
# copy this script inside the folder where the files are located and run it.
# The folder should only have the files you want to standardize. The script does:
# - change file name to lowercase
# - removes non ascii characters
# - replaces spaces by _

# This script is not meant to be short or fast, but rather easy to read and change.

file_to_lower() {
	local FILENAME	# file name without the extension
	local FILEEXT	# just the file's extension

	for file in *; do
		FILENAME="$(echo "${file%.*}" | tr '[:upper:]' '[:lower:]')"
		FILEEXT="$(echo "${file##*.}" | tr '[:upper:]' '[:lower:]')"

		if [ $FILEEXT != 'sh' ]; then
			if [ "$file" != "$FILENAME.$FILEEXT" ]; then
				mv "$file" "$FILENAME.$FILEEXT"
			fi
			echo "Changed extension to lower case: '$FILENAME'.'$FILEEXT'"
		fi
	done
}

remove_non_ascii() {
	local FILENAME	# whole name, including extension
	local FILEEXT	# just the file's extension

	for file in *; do
		FILENAME="$(echo "$file" | tr -cd "a-zA-Z0-9._- ñáéíóú")"
		FILEEXT="${file##*.}"

		if [ $FILEEXT != 'sh' ]; then
			if [ "$file" != "$FILENAME" ]; then
				mv "$file" "$FILENAME"
			fi
			echo "Removed non ascii chars for: '$FILENAME'"
		fi
	done
}

replace_spaces() {
	# replaces spaces and '-'' with '_'
	local FILENAME	# whole filename
	local FILEEXT	# just the file's extension

	for file in *; do
		FILENAME="$(echo "$file" | tr -s ' ' '_')"
		FILENAME=$(echo "$FILENAME" | tr -s '-' '_')
		FILENAME=$(echo "$FILENAME" | tr -s '_' '_')
		FILEEXT="${file##*.}"

		if [ $FILEEXT != 'sh' ]; then
			if [ "$file" != "$FILENAME" ]; then
				mv "$file" "$FILENAME"
			fi
			echo "Removed spaces, new file name: $FILENAME"
		fi
	done
}

file_to_lower
remove_non_ascii
replace_spaces

How to Enable FiiO E07’s Digital Output in Linux Mint / Ubuntu

FIIO Andes

FIIO Andes

I have seen this question asked several times in forums, and I used to have this issue too. It is a bummer not to have digital output when normally that’s the whole reason why you buy a DAC!

The solution is simple but a little bit of a nuisance: Connect the FiiO Andes to your laptop before you turn it on!. If you disconnect it and reconnect it while the computer is on, your digital output will not come back until next time you restart your pc.

 

DAC

DAC

If you put your computer into hibernation because you have applications you don’t want to close, as long as you keep the DAC connected until the computer hibernates, and you connect it back before waking up the laptop, your digital output will still be available.

Free Antivirus For Linux Mint / Ubuntu Desktop

You may think that there is no need for antivirus in Linux, so far I don’t think you need active protection, but having the option to scan folders and flash drives is always nice. I also use them to cleanup Windows machines’ hard drives.

BitDefender
BitDefender is my favorite one, you can apply for a free personal licence here, and you can install it by:

# Add the BitDefender repository key to the list of apt trusted keys:
wget http://download.bitdefender.com/repos/deb/bd.key.asc
sudo apt-key add bd.key.asc

# Add the following line to the /etc/apt/sources.list file:
deb http://download.bitdefender.com/repos/deb/ bitdefender non-free

# Refresh your apt cache by running:
apt-get update

# Install the desired BitDefender packages:
apt-get install bitdefender-scanner-gui

ClamAv
ClamAv does have a full GUI, and have many other packages available for servers. The installation for desktop is very simple:

# Install the engine, updater and GUI:
sudo apt-get install clamav clamav-freshclam clamtk

# To also install active protection:
sudo apt-get clamav-daemon 

# To update the virus definitions:
sudo freshclam