Skip to main content

I have the following folder and files:

. ├── photos │ ├── photo-a │ │ ├── photo-a.meta.json │ │ ├──└── photo-a.json │ ├── photo-b │ │ ├── photo-b.meta.json └───└───└──│ │  └── photo-b.json ... There are more folders and files in the photos folder in the same structure 

I would want to copy all the files photo-a.json, photo-b.json and others into another folder called photos-copy. Basically, I want to exclude all the files that end with .meta.json but copy only those that end with .json files.

So, if done correctly, photos-copy folder would look like this:

. ├── photos-copy │ ├── photo-a.json └───└──│ └── photo-b.json ... 

I tried something along cp -a ./photos/*.json ./photos-copy but this will end up copying everything because the .meta.json files also end with .json extensions.

How can I do this?

I have the following folder and files:

. ├── photos │ ├── photo-a │ │ ├── photo-a.meta.json │ │ ├── photo-a.json │ ├── photo-b │ │ ├── photo-b.meta.json └───└───└── photo-b.json ... There are more folders and files in the photos folder in the same structure 

I would want to copy all the files photo-a.json, photo-b.json and others into another folder called photos-copy. Basically, I want to exclude all the files that end with .meta.json but copy only those that end with .json files.

So, if done correctly, photos-copy folder would look like this:

. ├── photos-copy │ ├── photo-a.json └───└── photo-b.json ... 

I tried something along cp -a ./photos/*.json ./photos-copy but this will end up copying everything because the .meta.json files also end with .json extensions.

How can I do this?

I have the following folder and files:

. ├── photos │ ├── photo-a │ │ ├── photo-a.meta.json │ │ └── photo-a.json │ ├── photo-b │ │ ├── photo-b.meta.json │ │  └── photo-b.json ... There are more folders and files in the photos folder in the same structure 

I would want to copy all the files photo-a.json, photo-b.json and others into another folder called photos-copy. Basically, I want to exclude all the files that end with .meta.json but copy only those that end with .json files.

So, if done correctly, photos-copy folder would look like this:

. ├── photos-copy │ ├── photo-a.json │ └── photo-b.json ... 

I tried something along cp -a ./photos/*.json ./photos-copy but this will end up copying everything because the .meta.json files also end with .json extensions.

How can I do this?

deleted 80 characters in body
Source Link
xenon
  • 133
  • 1
  • 1
  • 5

I have the following folder and files:

. ├── photos │ ├── photo-a │ │ ├── photo-a.meta.json │ │ ├── photo-a.json │ ├── photo-b │ │ ├── photo-b.meta.json └───└───└── photo-b.json ... There are more folders and files in the photos folder in the same structure 

I would want to copy all the files photo-a.json, photo-b.json and others into another folder called photos-copy while preserving the folder structure. Basically, I want to exclude all the files that end with .meta.json but copy only those that end with .json files.

So, if done correctly, photos-copy folder would look like this:

. ├── photos-copy │ ├── photo-a │ │ ├── photo-a.json │ ├── photo-b └───└───└──└───└── photo-b.json ... 

I tried something along cp -a ./photos/*.json ./photos-copy but this will end up copying everything because the .meta.json files also end with .json extensions.

How can I do this?

I have the following folder and files:

. ├── photos │ ├── photo-a │ │ ├── photo-a.meta.json │ │ ├── photo-a.json │ ├── photo-b │ │ ├── photo-b.meta.json └───└───└── photo-b.json ... There are more folders and files in the photos folder in the same structure 

I would want to copy all the files photo-a.json, photo-b.json and others into another folder called photos-copy while preserving the folder structure. Basically, I want to exclude all the files that end with .meta.json but copy only those that end with .json files.

So, if done correctly, photos-copy folder would look like this:

. ├── photos-copy │ ├── photo-a │ │ ├── photo-a.json │ ├── photo-b └───└───└── photo-b.json ... 

I tried something along cp -a ./photos/*.json ./photos-copy but this will end up copying everything because the .meta.json files also end with .json extensions.

How can I do this?

I have the following folder and files:

. ├── photos │ ├── photo-a │ │ ├── photo-a.meta.json │ │ ├── photo-a.json │ ├── photo-b │ │ ├── photo-b.meta.json └───└───└── photo-b.json ... There are more folders and files in the photos folder in the same structure 

I would want to copy all the files photo-a.json, photo-b.json and others into another folder called photos-copy. Basically, I want to exclude all the files that end with .meta.json but copy only those that end with .json files.

So, if done correctly, photos-copy folder would look like this:

. ├── photos-copy │ ├── photo-a.json └───└── photo-b.json ... 

I tried something along cp -a ./photos/*.json ./photos-copy but this will end up copying everything because the .meta.json files also end with .json extensions.

How can I do this?

Source Link
xenon
  • 133
  • 1
  • 1
  • 5

How can I copy all files while excluding files with a certain pattern?

I have the following folder and files:

. ├── photos │ ├── photo-a │ │ ├── photo-a.meta.json │ │ ├── photo-a.json │ ├── photo-b │ │ ├── photo-b.meta.json └───└───└── photo-b.json ... There are more folders and files in the photos folder in the same structure 

I would want to copy all the files photo-a.json, photo-b.json and others into another folder called photos-copy while preserving the folder structure. Basically, I want to exclude all the files that end with .meta.json but copy only those that end with .json files.

So, if done correctly, photos-copy folder would look like this:

. ├── photos-copy │ ├── photo-a │ │ ├── photo-a.json │ ├── photo-b └───└───└── photo-b.json ... 

I tried something along cp -a ./photos/*.json ./photos-copy but this will end up copying everything because the .meta.json files also end with .json extensions.

How can I do this?