Skip to main content
More variations on a theme. I prefer Rachmaninoff's variations though
Source Link
Chris Davies
  • 128.3k
  • 16
  • 179
  • 324

A couple of options spring to mind.

rsync --dry-run -av --prune-empty-dirs --exclude '*.meta.json' --include '*.json' photos/ photos-copy/ 

Or if you don't have rsync (and why not!?), this will copy the files retaining the structure

cp -av photos/ photos-copy/ rm -f photos-copy/*/*.meta.json 

This variant will flatten the files into a single directory

cp -av photos/*/*.json photos-copy/ rm -f photos-copy/*.meta.json 

You can do more fancy things with bash and its extended pattern matching, which here tells the shell to match everything that does not contain .meta in its name:

shopt -s extglob cp -av photos/*/!(*.meta).json photos-copy/ 

A couple of options spring to mind.

rsync --dry-run -av --prune-empty-dirs --exclude '*.meta.json' --include '*.json' photos/ photos-copy/ 

Or if you don't have rsync (and why not!?),

cp -av photos/ photos-copy/ rm -f photos-copy/*/*.meta.json 

A couple of options spring to mind.

rsync --dry-run -av --prune-empty-dirs --exclude '*.meta.json' --include '*.json' photos/ photos-copy/ 

Or if you don't have rsync (and why not!?), this will copy the files retaining the structure

cp -av photos/ photos-copy/ rm -f photos-copy/*/*.meta.json 

This variant will flatten the files into a single directory

cp -av photos/*/*.json photos-copy/ rm -f photos-copy/*.meta.json 

You can do more fancy things with bash and its extended pattern matching, which here tells the shell to match everything that does not contain .meta in its name:

shopt -s extglob cp -av photos/*/!(*.meta).json photos-copy/ 
Source Link
Chris Davies
  • 128.3k
  • 16
  • 179
  • 324

A couple of options spring to mind.

rsync --dry-run -av --prune-empty-dirs --exclude '*.meta.json' --include '*.json' photos/ photos-copy/ 

Or if you don't have rsync (and why not!?),

cp -av photos/ photos-copy/ rm -f photos-copy/*/*.meta.json