📜 ⬆️ ⬇️

Automatic copying of CD / DVD to HDD

A long time ago I wrote a set of crutches for automatic copying of disks under windows .

Now I itch the same under linux.

The script relies heavily on testing udev automounting and is sharpened by the current state of affairs in lenny (and, most likely, in bubunts). There is a situation of several CDs (processed first) and the presence of loop-devices (mounted by ISO), they are skipped.
')
The principle of operation: run the script, insert the disc, it was copied, the disc came out as soon as the next one was inserted, it was copied again. Great for copying a pack of discs without distraction from pressing buttons on the keyboard.

 #! / bin / sh
 target = "/ pub / anime / from_cd"

 while true
 do
         mounted_cd_path = `mount | grep -v / dev / loop | grep iso9660 | head -n 1 | awk '{print $ 3}'`
         mounted_cd_device = `mount | grep" $ mounted_cd_path "| awk '{print $ 1}'`
         if [$ mounted_cd_path- = -]
         then
                 sleep 5
                 continue
         else
                 name = `volname $ mounted_cd_device`
                 echo $ name: $ mounted_cd_device mounted to $ mounted_cd_path
                 mkdir $ target / $ name
                 cp -R $ mounted_cd_path / * $ target / $ name
                 eject $ mounted_cd_device
                 echo "ejected please Ctrl-C to exit"
         fi
 done

Source: https://habr.com/ru/post/96920/


All Articles