I'm looking to auto copy the contents off of a disc on insert to a specified directory. It's not a DVD or cd simply one data file on every disc, would it be possible to do this with a shell script?
Yes Indeedy! I got interested so did some head scratching and a good deal of teeth nashing and hair pulling. Here it is:
You'll notice that the script assume that the cdrom is /dev/sr0 so if this is not the case you'll need to change it. Use the blkid command to find out what your optical device is called. The script copies everything to your home folder in a subdirectory called junk, and this directory must exist before you run the script.
I found the script ejects the cd/dvd nicely once the data is copied. If it doesn't eject and stays mounted I think it will try to copy the same disk all over again. Apart from that it's pretty self explanatory. Enjoy :-)
Both top answers worked perfectly.
Fabricator4: I changed the line
If you want to make a reaction when you insert a dvd/cd you need to write an udev rule.
You can find instructions here
Look into the section on running programs on specific events.
First identify the device by doing a
Add a new rule file