Tag: copy directory structure

Linux one liner to copy files with directory structure

ol

Here is another one liner to find multiple file types and copy them along with the directory structure to the destination.

I was searching for copying all pics and video files from my computer to USB hard drive. While googling around I got this command.

find /home -regextype posix-extended -regex ‘.*(MOV|JPG)’ -exec cp –parents {} /media/vin/desktop \; -print

This can be handy when you don’t want to loose the directory structure and want to copy all similar type of files in one go. Above command looks complex but still it is one line command.. Have fun with Linux and you’ll enjoy exploring this OS 🙂

Advertisements