Just how can I relocate files by type recursively from a directory and also its sub-directories to an additional directory?

What would certainly be an excellent way to relocate a documents type from a directory and also all of its sub-directories?

Like "relocate all *. ogg in/ thisdir recursively to/ somedir". I attempted a number of points; my best shot was (still not that wonderful) :

find /thisdir -type f -name '*.ogg' -exec mv /somedir {} \;

It returned on each line prior to each documents name,

mv: cannot overwrite non-directory `/thisdir/*.ogg' with directory `/somedir'
2019-05-04 12:16:01
Source Share
Answers: 3
find /thisdir -type f -name "*.ogg" -exec mv {} /somedir \;

You kinda swapped the debates for mv

2019-05-07 23:51:39

In zsh or celebration 4, to collect all *.ogg submits right into /somedir :

mv /thisdir/**/*.ogg /somedir

If you intended to duplicate the directory power structure : (caution, keyed in straight right into the internet browser )

rsync -a --prune-empty-dirs --include='*/' --include='*.ogg' --exclude='*' /thisdir /somedir
2019-05-07 23:48:24

you can make use of find with xargs for this

find /thisdir -type f -name "*.ogg" -print0 | xargs -0 -Imysongs mv -i mysongs /somedir

The -I in the above command informs xargs what substitute string you desire to make use of (or else it includes the debates throughout of the command ).

In your command simply attempt to relocate' ' after mv command.

find /thisdir -type f -name '*.ogg' -exec mv -i {} /somedir \;

2019-05-07 23:38:24