Is it possible to move thousands of files in a directory with a specific file extension to a different directory?For example, there are .cpp and .hpp directories. Move all .hpp files in the .cpp directory to the .hpp directory.mv**/*. If you try to use hpp/path/to/single/target/directory
, you will not be able to handle many files.
The -exec
option of the find
command is available.However, please note that the behavior is not obvious when trying to move to a subdirectory.
find<Searching Directory >-type f-name "*.hpp" -exec mv{}<Move to Directory >\;
Alternatively, the GNU version of mv can be written as follows:
find<Searching Directory >-type f-name "*.hpp" -exec mv --target-directory=<Traveling Directory >{}+
find cpp-name "*.hpp"-print | xargs-I@mv@hpp
© 2024 OneMinuteCode. All rights reserved.