Saturday, November 28, 2009

Static mount to Dlink DNS323 Samba Share

Here is the /etc/fstab entry that successfully mounts the Samba share from my Dlink DNS323.

This mounts the whole 'Volume_1' share under '/media/nas01'


//192.168.0.4/Volume_1  /media/nas01    cifs    username=user1,password=pass1,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

Friday, November 27, 2009

Archiving screenshot images with script

Often I take screenshots of the receipts from transactions that I complete online like paying bills or buying stuff. But I need some quick way of archiving these as they often just end up being called "Screenshot.png", "Screenshot-1.png", etc.

Here is a bash script that I hacked together from snippets I found on the net. This rename and move the files from one location to another. The new name will be a combination of the create time and the original file name.

#!/bin/bash

## Variables ##
orig_location="/home/user/Desktop"
orig_name="*.png"
new_location="/media/nas01/private/documents/records/screen_grabs"

## Script ##
# file all files in original location with original name and loop thru following...
find ${orig_location} -iname "${orig_name}" | while read FILE; do
 # Use 'stat' to extract the modification time
mtime=($(stat -c "%y" "${FILE}"))
 # get the name (without path) and convert to lower
NFILE=($(echo $(basename ${FILE}) | tr '[:upper:]' '[:lower:]'))
 # move the file to new location and prepend create time to filename
mv -f "${FILE}" "${new_location}/${mtime[0]//-/}_${NFILE}"
done