6

This question already has an answer here:

I have a folder named 'Java' which has 20 sub folders ('Day-01' to 'Day-20'). Each sub folder has one or two '.wav' files along with few other files. I want to copy the entire directory except the '.wav' files via terminal. How do I do this?

marked as duplicate by muru command-line Jun 13 '16 at 19:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

12

The easiest way would be to use rsync with the --exclude option to exclude to .wav files from copying:

rsync -av --exclude='*.wav' /path/to/Java /out/dir

Example:

/foobar/Java% tree
.
├── day-01
│   ├── 01.sh
│   ├── 01.txt
│   └── 01.wav
├── day-02
│   ├── 02.sh
│   ├── 02.txt
│   └── 02.wav
├── day-03
│   ├── 03.txt
│   └── 03.wav
├── day-04
│   └── 04.txt
└── day-05
    └── 05.wav

/foobar/out% rsync -av --exclude='*.wav' ../Java .
sending incremental file list
Java/
Java/day-01/
Java/day-01/01.sh
Java/day-01/01.txt
Java/day-02/
Java/day-02/02.sh
Java/day-02/02.txt
Java/day-03/
Java/day-03/03.txt
Java/day-04/
Java/day-04/04.txt
Java/day-05/

sent 564 bytes  received 158 bytes  1,444.00 bytes/sec
total size is 0  speedup is 0.00

/foobar/out% tree
.
└── Java
    ├── day-01
    │   ├── 01.sh
    │   └── 01.txt
    ├── day-02
    │   ├── 02.sh
    │   └── 02.txt
    ├── day-03
    │   └── 03.txt
    ├── day-04
    │   └── 04.txt
    └── day-05
  • 1
    Excellent!! Thank you so much for the beautiful explanation. Worked like a charm! – optimist Jun 13 '16 at 12:17
  • @optimist if the answer solved your question, please accept this answer as a valid solution by clicking the grey checkmark next to the up and down arrows. Thank you for cooperation and welcome to AskUbuntu ! – Sergiy Kolodyazhnyy Jun 13 '16 at 12:18
0

The easiest way is proably to use rsync:

rsync -avz --exclude "*.wav" SOURCE_DIR DESTINATION_DIR

Not the answer you're looking for? Browse other questions tagged or ask your own question.