Skip to content

Instantly share code, notes, and snippets.

@cmeon
Created August 5, 2015 12:03
Show Gist options
  • Select an option

  • Save cmeon/69adbaedf1cb6a23b4e9 to your computer and use it in GitHub Desktop.

Select an option

Save cmeon/69adbaedf1cb6a23b4e9 to your computer and use it in GitHub Desktop.
This file groups every file according to its filename
#!/bin/bash
# This file groups every file according to its filename
# Inspiration came from wanting to group different classes
# and their header files in separate folders
# Get filenames
echo "Getting filenames"
FILE_LIST=$(basename -as .h *)
# Create folders based on filenames
echo "Grouping files..."
for FILENAME in $FILE_LIST
do
FOLDER=$FILENAME
mkdir $FOLDER
mv $FILENAME.* $FOLDER
done
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment