SD card autocopy (Linux)

0 1383 0

SD card autocopy (Linux)

linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux


linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux 

Copying photos from the SD card of my camera is a very common task. And always the same pattern. Take the card out of the camera, put it into the sd card reader, wait for the automount popup, browse to the picture directory, select all images, cut all images, browse to my photo directory, create a new folder, name the folder, move to the folder, paste the pictures into it, wait for the finished job.

Sound boring? Sure, it is! -linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux 

Now, how to make this one a little smarter? Maybe scripting some of those steps is a cool idea. So how would this work in a perfect world?

The sd-autocopy script

linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux ,

With these information the SD card can be identified. It will use the ID_SERIAL and DEVNAME environment variables in the script. Now I identified the tasks which need to be performed by the sd-autocopy script:

  1. Verify the sd card to be a handled one
  2. Mount the partition
  3. Find all images on the partition
  4. Create a folder for each date in a target base path
  5. Move the files to the date specific folder
  6. Unmount the partition

The script is placed in /usr/local/bin/sd-autocopy (just remove the testing code from that file). The finished script can be found in the git next to this README file.

linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux 

The script can easily be extended by modifying the first few lines:

USER=lmTARGET=/home/$USER/Pictures/PhotosHANDLED_SERIALS="0x000006d4"MOUNT=/mnt/sd-autocopyFILE_MATCH=".*\.(jpg|cr2)$"# Move or copy - or something differentTRANSFER=mv
  • USER is needed a) for gathering the target directory and b) for owning the copied files.
  • TARGET holds the path to the target base directory.
  • HANDLED_SERIALS holds a list of space separated serial numbers of the SD cards to use the script for.
  • MOUNT contains the mountpoint for the first partition on the SD card.
  • FILE_MATCH is the matching regex for the files to be copied. It applies to the whole path of the files.
  • TRANSFER defines the transfer mode. For example "mv" to move the files or "cp" to copy them.

The script sends it's log entries to syslog, so you might want to have a look at the syslog files for debugging.

Btw. the script is not limited to handling images. By just modifying the FILE_MATCH pattern it is possible to copy other filetypes.

linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux ,linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux

linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux ,linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux

linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux ,linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux

linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux ,linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux

linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux ,linux sd card,ubuntu sd card,sd card copier ubuntu,microsd linux,sd linux

Tag: linux sd card sd linux ubuntu sd card micro sd linux sd card copier ubuntu