Skip to content

Instantly share code, notes, and snippets.

@abhinavjain241
Created September 19, 2015 13:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhinavjain241/9243210d0a0c2f4f1769 to your computer and use it in GitHub Desktop.
Save abhinavjain241/9243210d0a0c2f4f1769 to your computer and use it in GitHub Desktop.
[Shell Script] Make directories in a folder for each of your file.
#!/bin/bash
# Reference: (Thanks StackOverflow) - http://stackoverflow.com/questions/2859908/iterating-over-each-line-of-ls-l-output
# Copy the script into a folder. Run it. This will make a folder for each of your file present in the directory.
# Helps me to organize my Movie collection.
ls -p | grep -v / | while read x; do if [[ $x != "MakeDirectory.sh" ]]; then mkdir "${x%.*}"; mv "$x" "${x%.*}"; fi done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment