Skip to content

Instantly share code, notes, and snippets.

@flatlinebb
Created October 29, 2020 15:48
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 flatlinebb/c9d34767dc60189e08be1a5601ef499b to your computer and use it in GitHub Desktop.
Save flatlinebb/c9d34767dc60189e08be1a5601ef499b to your computer and use it in GitHub Desktop.
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