Anybody know where I am going wrong? I have tried different variations…
Stephen Marsh
The script was designed to run from a file on the contents of the directory that file is located in. ${BASH_SOURCE[0]} evaluates to the path of the script, then the script changes the working directory to be its location. When automator runs it, there isn't really a source file, so ${BASH_SOURCE[0]} evaluates to nothing and "cd " is probably what gets executed, which would leave the working directory the home directory of the user who executed it (e.g., /Users/YourName). If you had any TIFF files in your home directory, you might want to check your home directory for a "MULTIPLE LAYERS" directory.
You'll want to change "Pass input" from "to stdin" to "as arguments" (otherwise it would be next to impossible to correctly separate multiple files if any of their names contained spaces).
When you switch from running a script from a file on all of its sibling TIFF files to all of the files selected in Finder, a few complications are introduced. The files selected when the script is invoked are not necessarily in the same directory, so they could potentially have identical names, which wouldn't work if they needed to be moved to the same directory. You might also not know where the files originally came from if files from multiple directories were moved into the same directory.
I've attached a not-heavily-tested version that will probably work (the forum apparently kills the whitespace formatting if I just paste it here). To avoid the multiple source directory problem, it should figure out the deepest directory containing all selected files, put the "MULTIPLE LAYERS" directory there, then recreate the subdirectories from that point within the "MULTIPLE LAYERS" directory.
Since there's no terminal window to report that it's finished in, it creates a notification (Mountain Lion or newer required). Enabling permissions for osascript can be a pain in newer versions of OS X - you may just want to remove the last line if you don't expect to run this on hundreds of files at a time.