Nick's Tech Blog: August 2011

Pages

Tuesday, August 23, 2011

Linux > tag files in a directory by directory name

Work in progress...


#!/bin/bash
#
# "tagdirs.sh"
#
# Simple script which iterates over the first level folders in a given directory,
# and tags the files in those subdirectories with the parent folder's name.
#
# Usage: ./tagdirs.sh
#
# N.B. Requires 'tracker-tag'.
#

# The folder to iterate over.
FOLDER=$1

# Check param is a directory...
if [ -d "${1}" ] ; then
echo "Processing directory '${1}'..."
else
echo "Error: bad argument. Expected a valid directory name for the first argument"
echo "Bad directory name = ${1}"
exit 1
fi

(
IFS=$'\n'
# For each directory...
for dir in $(find $FOLDER -maxdepth 1 -mindepth 1 -type d); do
# Strip directory to folder name only...
tag=${dir##*/}
# For each file in the directory...
for file in $(find $dir -maxdepth 1 -mindepth 1 -type f); do
echo "Adding tag '${tag}' to file '${file}'...";
tracker-tag --add="${tag}" "${file}"
done
done
)

exit 0

Monday, August 22, 2011

Stream content from Ubuntu to an Xbox360

Problem

I wanted to setup Ubuntu (11.04), so that I could access content from an Xbox360 using DLNA

Solution

  1. Open "Ubuntu Software Center" and install "rygel"
  2. Also install the additional "Tracker plugin" (only)
  3. Follow the steps under Helper Scripts (requires sqlite3)
Rygel can now be started from the terminal by executing "rygel".
    Movies/Pictures/Video's tagged in nautilius will be displayed (right click on the file and tag).

    See also:
    http://live.gnome.org/Rygel
    http://en.wikipedia.org/wiki/Digital_Living_Network_Alliance

    Installing Netgear WG311v3 Wireless Network Card on Ubuntu 11.04 amd64

    Problem

    The Netgear WG311v3 Wireless Network Card driver isn't automatically installed by Ubuntu 11.04.

    Solution

    1. Download and extract the custom driver from the following website.
    2. Open "Ubuntu Software Center" and install "ndiswrapper" (i.e. Windows Wireless Drivers)
    3. Open "Windows Wireless Drivers", and install the "WG311v3.INF" driver.
    4. Save and close.
    Give the system a couple of seconds, and it should recognise your wireless card. And thats it.

    See also:
    https://help.ubuntu.com/community/WifiDocs/Device/Netgear_WG311_v3