Quantcast
Channel: Copy only files with certain extension while renaming each file according to the parent folder - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 2

Copy only files with certain extension while renaming each file according to the parent folder

$
0
0

I have several directories:

├── folder1.x
│   ├── dsferwe
│   ├── ewrwr342
│   ├── analysis
│   ├── fdsds
│   ├── vcxvcxz
│   ├── 324322
│   ├── export.asc
│   ├── f_random_subfolder.xf
│   │   ├── -.method
│   │   ├── desktop.ini
│   │   ├── lock.file
│   │   └── submethods.xml
│   └── Sync
├── random_folder4.x
│   ├── dsferwe
│   ├── ewrwr342
│   ├── analysis
│   ├── fdsds
│   ├── vcxvcxz
│   ├── 324322
│   ├── export.asc
│   ├── 22random_subfolder.xf
│   │   ├── -.method
│   │   ├── desktop.ini
│   │   ├── lock.file
│   │   └── submethods.xml
│   └── Sync
├── X93430.x
│   ├── dsferwe
│   ├── ewrwr342
│   ├── analysis
│   ├── fdsds
│   ├── vcxvcxz
│   ├── 324322
│   ├── export.asc
│   ├── random_subfolder222.xf
│   │   ├── -.method
│   │   ├── desktop.ini
│   │   ├── lock.file
│   │   └── submethods.xml
│   └── Sync

Each directory contains an export.asc file.

I want to copy all export.asc files to a new directory while renaming to have the same name as their parent directory. Therefore, in the end according to the example above I will have these files in a new folder:

folder1.x.asc
random_folder4.x.asc
X93430.x.asc

How can I achieve this?

RELATED topics I have already followed but haven't had any success


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images