danieljay
Posts: 49
Joined: Sun Sep 16, 2012 5:01 pm
Contact: Website

Automatically extract specific files usb drive

Sun Dec 01, 2013 7:29 am

Hey all,

I'm trying to find a simple script (or other suggestions welcome) to automatically extract specific files with specific file extensions from any inserted USB thumb drive into a directory on the Pi. I'm a bit lost on figuring out the best approach

hamster
Posts: 23
Joined: Fri Sep 23, 2011 10:20 pm

Re: Automatically extract specific files usb drive

Sun Dec 01, 2013 8:05 am

Hi!

Something like this does what you asked for:

Code: Select all

mnt /dev/sda /mnt
find /mnt -name '*.ext' -type f -exec cp {} /destination_dir
umount /mnt/sda
It does however dump the files into the one directory. If you want to to preserve the directory tree structure under the destination directory then you maybe "rsync" with some filter switches (e.g. "--include") will prove more useful.

See "man rsync" for more info.

danieljay
Posts: 49
Joined: Sun Sep 16, 2012 5:01 pm
Contact: Website

Re: Automatically extract specific files usb drive

Sun Dec 22, 2013 2:57 am

great! thanks so much!

Return to “Advanced users”