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?
-
You can copy everything then delete the .wav files by extension in that folder and subfolders– PartoJun 13, 2016 at 11:46
-
copy of See this solution– ZiazisJun 13, 2016 at 11:46
-
@parto the op probably wants to avoid the time delay in copying the same (maybe large) audio file 20 times when they don't need to– Azor Ahai -him-Jun 13, 2016 at 17:20
Add a comment
|
2 Answers
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
-
1Excellent!! Thank you so much for the beautiful explanation. Worked like a charm!– optimistJun 13, 2016 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 ! Jun 13, 2016 at 12:18
The easiest way is proably to use rsync:
rsync -avz --exclude "*.wav" SOURCE_DIR DESTINATION_DIR