Created
March 23, 2024 16:36
-
-
Save mkdizajn/d9721404a81ffc30d009d8b94080272b to your computer and use it in GitHub Desktop.
BASH_ make items in subdirs flat in top dir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# >>>>>>>>> | |
# script to copy this structure - TO NEW DIRECTORY: | |
# slike1 | |
# ├── 12063DSC04233.JPG | |
# ├── 27454DSC04230.JPG | |
# └── sub1 | |
# ├── 15997DSC04140.JPG | |
# └── sub12 | |
# └── 25022DSC04150.JPG | |
# <<<<<<<<< | |
# to this structure (note random file prefix for legit dups): | |
# slike2 | |
# ├── 10892-25022DSC04150.JPG | |
# ├── 19939-15997DSC04140.JPG | |
# ├── 21121-27454DSC04230.JPG | |
# └── 22714-12063DSC04233.JPG | |
find ./slike/* -type f | | |
while IFS= read -r name; do # Read one line and store it in variable $name | |
cp "${name}" "./slike1/$RANDOM-${name##*/}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment