Skip to content

Instantly share code, notes, and snippets.

@flatlinebb
Created October 29, 2020 15:48
Show Gist options
  • Select an option

  • Save flatlinebb/c9d34767dc60189e08be1a5601ef499b to your computer and use it in GitHub Desktop.

Select an option

Save flatlinebb/c9d34767dc60189e08be1a5601ef499b to your computer and use it in GitHub Desktop.

Revisions

  1. flatlinebb created this gist Oct 29, 2020.
    11 changes: 11 additions & 0 deletions rename-to-folder.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # 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