Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rename files to the folder name. Move all files from subfolders to root. Remove empty folders.
# To verify first, just echo instead of move:
for f in */* ; do fp=$(dirname "$f"); ext="${f##*.}" ; echo "$f" "$fp"/"$fp"."$ext" ; done
# Rename for realz:
for f in */* ; do fp=$(dirname "$f"); ext="${f##*.}" ; mv "$f" "$fp"/"$fp"."$ext" ; done
# Move all files to root:
mv *.mkv */*.mkv .
# Delete all empty folders in current directory:
find . -type d -empty -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment