You are not logged in.

#1 2012-02-17 15:39:19

Redostrike
Member
Registered: 2010-02-07
Posts: 37

Software/Script USB/SD auto copy.

Hi,

I have a server which i want to be as automated as i can get it. I'm using it for an fileserver (and other things). What i want to accomplish is when i insert my SD from my camera that the server automatically copy's the files in from the sd cards picture folder to a new folder (which needs to be created automatically with the date YYYY-MM-DD-HH-MM exp 2012-02-17-12:22) to the server. I would also need something in the likes of this for an usb stick i use for work. Files in a specific folder need to be copy to another folder (which already exists on the server).

I'm not sure if this can be done trough software or i need to start learning some scripting.

Thanks in advance.

Offline

#2 2012-02-17 20:38:49

namelessone
Member
Registered: 2009-12-17
Posts: 39

Re: Software/Script USB/SD auto copy.

Your best bet would probably be some simple BASH scripting. The only real trick is detecting when the SD card is inserted. I think you would probably need to write a custom udev rule that executes your script when a SD/USB device is mounted.

Here's some framework to get you started:

#/bin/bash
#SDdump.sh
#usage: SDdump.sh <device>

DIR=`date +%Y-%d-%H:%M`

#some sort of error checking
if [ -e $1 ]; then
  echo "$1 does not exist"
  return
fi

#move to and create new directory
cd /home/user/My_Pictures
mkdir $DIR
cd $DIR

#copy pictures
cp -r $1/*.jpg .

Offline

Board footer

Powered by FluxBB