Giter Site home page Giter Site logo

sd-autocopy's Introduction

SD card autocopy

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!

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 idea

Taking the SD card out of the camera and putting it into the SD card reader does not seem to be easily scripted, that's why I focused on the other steps ;-). Okay, I'd like to put the card into the reader, just wait for all the images to be moved and then put the card back into the camera.

But how to reach this goal? Maybe you're interested in my solution...

Get the USB device unit

Plug in the usb drive and run

systemctl --all list-units

$ systemctl --all list-units
  UNIT                                                                                                                  LOAD      ACTIVE   SUB       DESCRIPTION                                                                        
โ— boot.automount                                                                                                        not-found inactive dead      boot.automount                                                                     
  dev-disk-by\x2did-usb\x2dTS\x2dRDF5_SD_Transcend_000000000039\x2d0:0.device                                           loaded    active   plugged   SD_Transcend                                                                       
  dev-disk-by\x2did-usb\x2dTS\x2dRDF5_SD_Transcend_000000000039\x2d0:0\x2dpart1.device                                  loaded    active   plugged   SD_Transcend FIELD_CAM                                                             
  dev-disk-by\x2dlabel-FIELD_CAM.device                                                                                 loaded    active   plugged   SD_Transcend FIELD_CAM                                                             
  dev-disk-by\x2dpartuuid-1cae7fd0\x2d01.device                                                                         loaded    active   plugged   SD_Transcend FIELD_CAM                                                             

In this example the device unit is: dev-disk-by\x2dlabel-FIELD_CAM.device

$ cat /usr/lib/systemd/system/sd.service 
[Unit]
Description=Copy photos from SD card when inserted
Requires=dev-disk-by\x2dlabel-FIELD_CAM.device
After=dev-disk-by\x2dlabel-FIELD_CAM.device

[Service]
ExecStart=/usr/local/bin/sd-copy

[Install]
WantedBy=dev-disk-by\x2dlabel-FIELD_CAM.device

Copy the sd-copy script from this repository and make the script executable:

chmod +x /usr/local/bin/sd-copy

Manually unmount and remove the USB device.

Now simply plug the SD card of your choice into your SD card reader and plug the card reader into the USB port.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.