Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pabloaugusto/a60bff539b7c3d7fbc1455357f43049c to your computer and use it in GitHub Desktop.

Select an option

Save pabloaugusto/a60bff539b7c3d7fbc1455357f43049c to your computer and use it in GitHub Desktop.
Linux (bash / shell): Move or copy files to a folder based on a recursive search

Move all image files at any subfolder (recursively) to a single folder.

In the example below, I need to move all images from all subfolders to a single folder

find /absolute/path/to/images  -name '*.png' | xargs -I files mv files /absolute/image/newpath

find /absolute/path/to/videos  -name '*.mp4' | xargs -I files mv files /absolute/video/newpath

find /absolute/path/to/images  -name '*.jpg' | xargs -I files mv files /absolute/photo/newpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment