Skip to content

Instantly share code, notes, and snippets.

@sjvrijn
Created December 11, 2019 14:42
Show Gist options
  • Save sjvrijn/638926b5e0812e72146f8adb152e5fef to your computer and use it in GitHub Desktop.
Save sjvrijn/638926b5e0812e72146f8adb152e5fef to your computer and use it in GitHub Desktop.
invert directory hierarchy: A/B/* -> B/A/*
#!/bin/bash
for a in */; do
for b in $a/*/; do
dir=${b##*//}
mkdir -p $dir$a
mv $a$dir* $dir$a
done
rm -rf $a
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment