Skip to content

Instantly share code, notes, and snippets.

@drocamor
Created January 5, 2011 17:53
Show Gist options
  • Save drocamor/766683 to your computer and use it in GitHub Desktop.
Save drocamor/766683 to your computer and use it in GitHub Desktop.
To help sort out your multipass renders!
#!/bin/bash
# sort_renders.sh - Sorts multipass renders in a given directory
# usage: sort_renders.sh [directory]
## Here are some things to customize:
# Populate this with a list of all the pass names seperated by spaces
PASSNAMES="foo bar baz quux _ao"
# Set this to cp to copy or mv to move
COPY_OR_MOVE="cp"
## And here is the program:
function printUsage {
echo Please provide a directory of renders to sort
echo Usage: $0 [directory]
exit 1
}
# Check for a directory
if [ -z $1 ]; then
printUsage
fi
DIRECTORY=$1
# Find files in the unsorted directory that match the passname and move or copy them
for PASS in $PASSNAMES; do
echo Processing $PASS
find $DIRECTORY -maxdepth 1 -type f -name "*_$PASS*" -exec mkdir -p $DIRECTORY/$PASS ';' -exec $COPY_OR_MOVE {} $DIRECTORY/$PASS/ ';'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment