Skip to content

Instantly share code, notes, and snippets.

@kkweon
Last active February 22, 2018 06:07
Show Gist options
  • Save kkweon/a8e86d5ba2faebf4a7d3a9dc22ff5948 to your computer and use it in GitHub Desktop.
Save kkweon/a8e86d5ba2faebf4a7d3a9dc22ff5948 to your computer and use it in GitHub Desktop.

Directory Structure

tree
.
├── image1
│   ├── 1.png
│   ├── 2.png
│   ├── 3.png
│   ├── 4.png
│   └── 5.png
└── image2
    ├── 1.png
    ├── 2.png
    ├── 3.png
    ├── 4.png
    └── 5.png

2 directories, 10 files

echo

mkdir -p dest && find . -type f -name *.png | awk -F'/' '{ print $0" dest/"$2"-"$3}' | while read src dst; do cp $src $dst; done

Result

tree
.
├── dest
│   ├── image1-1.png
│   ├── image1-2.png
│   ├── image1-3.png
│   ├── image1-4.png
│   ├── image1-5.png
│   ├── image2-1.png
│   ├── image2-2.png
│   ├── image2-3.png
│   ├── image2-4.png
│   └── image2-5.png
├── image1
│   ├── 1.png
│   ├── 2.png
│   ├── 3.png
│   ├── 4.png
│   └── 5.png
├── image2
│   ├── 1.png
│   ├── 2.png
│   ├── 3.png
│   ├── 4.png
│   └── 5.png
└── README.org

3 directories, 21 files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment