Skip to content

Instantly share code, notes, and snippets.

@gjergjsheldija
Created August 22, 2016 11:28
Show Gist options
  • Save gjergjsheldija/335bde5690c336d0a47be56f5f4687ad to your computer and use it in GitHub Desktop.
Save gjergjsheldija/335bde5690c336d0a47be56f5f4687ad to your computer and use it in GitHub Desktop.
flatten directory structure and move files
#!/bin/bash
find */ -type f -exec bash -c 'file=${1#./};dir=${file%/*};echo mkdir "${dir/\//_}";echo mv "$file" "${file/\//_}"' _ '{}' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment