Skip to content

Instantly share code, notes, and snippets.

@organom
Last active December 2, 2020 14:30
Show Gist options
  • Save organom/ae1e1d4f4a3c884fcfa6a73859c773af to your computer and use it in GitHub Desktop.
Save organom/ae1e1d4f4a3c884fcfa6a73859c773af to your computer and use it in GitHub Desktop.
Flattern folder and file structure by extension, files will be moved to the current folder with the name being $DIR-$FILENAME.EXTENSION
EXTENSION=hl7
find . -type f -name "*.$EXTENSION" -printf "/%P\n" | while read FILE ; do DIR=$(dirname "$FILE" ); NAME=$(basename "$FILE" ); mv ."$FILE" ."$DIR-$NAME".$EXTENSION; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment