How can I move files by type recursively from a directory and its sub-directories to another directory?

Steve Burdine

What would be a good way to move a file type from a directory and all of its sub-directories?

Like "move all *.ogg in /thisdir recursively to /somedir". I tried a couple of things; my best effort was (still not that great):

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

It returned on each line before each file name,

mv: cannot overwrite non-directory `/thisdir/*.ogg' with directory `/somedir'
Hemant

you can use 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 tells xargs what replacement string you want to use (otherwise it adds the arguments to the end of the command).

OR
In your command just try to move '{}' after mv command.

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I move files by type recursively from a directory and its sub-directories to another directory?

From Dev

How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

From Dev

How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

From Dev

How to move all files (excluding sub-directories) from one directory to another?

From Dev

How can i move files from one directory to another?

From Dev

How can I move all files in subdirectories recursively to a single directory?

From Dev

How can I move all files in subdirectories recursively to a single directory?

From Dev

Move only files recursively from multiple directories into one directory with mv

From Dev

How to check for executable files in a given directory and its sub-directories?

From Dev

How can i add a recursive loop to delete a directory with all sub directories and files inside?

From Dev

How can I recursively list Md5sum of all the files in a directory and its subdirectories?

From Dev

How I can monitor new files in a directory and move/rename them into another directory?

From Dev

How to move mutliple files from multiple directories to one directory

From Dev

How do I move files from many child directories into my root directory?

From Dev

How to split a directory of files into sub-directories

From Dev

How can I copy a hidden directory recursively and preserving its permissions?

From Dev

How do I change the ownership of files within current directory, sub-directories, and sub-directories of sub-directories?

From Dev

How to get list of all files from a directory (including its sub-directories) whose file name contains a specific string

From Dev

How can i move some files from a directory to an other directory using a batch script?

From Dev

Recursively copy files from one directory to another

From Dev

Recursively copy files from one directory to another

From Dev

Loop through a directory and its sub-directories files in liquid

From Dev

How can I recursively grep particular files in a directory?

From Dev

How to move files and directories excluding one specific directory to this directory

From Dev

Recursively move files within sub directories

From Dev

How to count occurrences of a string ex. "sometext" in multiple .gz files in a directory and its sub directories?

From Dev

Windows: move images from sub directories into 1 directory

From Dev

move multiple directories in one directory - recursively

From Dev

How can I selectively copy files from one directory to another directory?

Related Related

  1. 1

    How can I move files by type recursively from a directory and its sub-directories to another directory?

  2. 2

    How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

  3. 3

    How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

  4. 4

    How to move all files (excluding sub-directories) from one directory to another?

  5. 5

    How can i move files from one directory to another?

  6. 6

    How can I move all files in subdirectories recursively to a single directory?

  7. 7

    How can I move all files in subdirectories recursively to a single directory?

  8. 8

    Move only files recursively from multiple directories into one directory with mv

  9. 9

    How to check for executable files in a given directory and its sub-directories?

  10. 10

    How can i add a recursive loop to delete a directory with all sub directories and files inside?

  11. 11

    How can I recursively list Md5sum of all the files in a directory and its subdirectories?

  12. 12

    How I can monitor new files in a directory and move/rename them into another directory?

  13. 13

    How to move mutliple files from multiple directories to one directory

  14. 14

    How do I move files from many child directories into my root directory?

  15. 15

    How to split a directory of files into sub-directories

  16. 16

    How can I copy a hidden directory recursively and preserving its permissions?

  17. 17

    How do I change the ownership of files within current directory, sub-directories, and sub-directories of sub-directories?

  18. 18

    How to get list of all files from a directory (including its sub-directories) whose file name contains a specific string

  19. 19

    How can i move some files from a directory to an other directory using a batch script?

  20. 20

    Recursively copy files from one directory to another

  21. 21

    Recursively copy files from one directory to another

  22. 22

    Loop through a directory and its sub-directories files in liquid

  23. 23

    How can I recursively grep particular files in a directory?

  24. 24

    How to move files and directories excluding one specific directory to this directory

  25. 25

    Recursively move files within sub directories

  26. 26

    How to count occurrences of a string ex. "sometext" in multiple .gz files in a directory and its sub directories?

  27. 27

    Windows: move images from sub directories into 1 directory

  28. 28

    move multiple directories in one directory - recursively

  29. 29

    How can I selectively copy files from one directory to another directory?

HotTag

Archive