Skip to content

Instantly share code, notes, and snippets.

@proclaim
Created February 21, 2019 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save proclaim/da0d52b479c82da0cecf434feca68f68 to your computer and use it in GitHub Desktop.
Save proclaim/da0d52b479c82da0cecf434feca68f68 to your computer and use it in GitHub Desktop.
Pull Files Out From Subdirectories
num=1
find . -mindepth 2 -type f -print | while read x; do
y=$(basename "$x")
if [ -f "$y" ]; then
mv "$y" "$num"."$y"
num=$(( $num + 1 ))
fi
mv "$x" "$y"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment