lundi 1 juillet 2019

How to move files found with pattern and move to another subdirectory in unix

I have this:

.
├── dirA
│   └── ProdA
│       ├── Brief
│       │   └── Form.xlsx
│       ├── Results
│       └── Studies
└── dirB
    └── BrandB
        └── ProdB
            ├── Brief
            │   └── Form.xlsx
            └── Results

and i want this:

.
├── dirA
│   └── ProdA
│       ├── Brief
│       ├── Results
│       └── Studies
│           └── Form.xlsx
└── dirB
    └── BrandB
        └── ProdB
            ├── Brief
            └── Results
            └── Studies  
                └── Form.xslx         

So basically i have to find files Form.xlsx and move it from subdirectory Brief to subdirectory Studies (create it if it does not exists), both at the same level.

when i do:

find . -name '*.xlsx' -exec mv '{}' ../Studies ';'

I got:

.
├── dirA
│   └── ProdA
│       ├── Brief
│       ├── Results
│       └── Studies
└── dirB
    └── BrandB
        └── ProdB
            ├── Brief
            └── Results

Aucun commentaire:

Enregistrer un commentaire