Search code examples
bashshell

How to move all files within subfolders into a new folder using bash?


I have a folder that I downloaded all my fonts to. When I opened the folder i noticed they were saved out into subfolders.

Is there a bash-shell script to grab all the files within the subfolders and move them to the parent folder?


Solution

  • You can move files with same extensions recursively using the wildcards. e.g. if you want to move all log files in nested folders under log/ directory into backup/ directory, you can use the following command:

    mv log/**/*.log backup/