I'm using Tag and Hazel and I'd like to recursively go through files on our server, obtain their file paths and filenames and parse the whole thing into tags to apply to the file. Is there a shell script that can do this? I can use Leap by Ironic Software to remove the trash tags system wide, but this gives me a real start into an automatic tagging system for all my files.
Basically I'm going to take a filename like
/Volumes/media/Clientele/Stock/Purchased Sets/Vintage Bundle/vintage-bundle-7/offset/30_CIRCULAR_VECTOR_TEXTURES/C03.eps
/Volumes/media/Clientele/Stock/ off the top, and the file extension
.eps from the end, then
cut the rest into separate tags:
- Purchased Sets
- Vintage Bundle
...remove leading and trailing spaces, change to lowercase, then reapply those tags back to the file with
Additionally, removing tags from the system that are just numbers would be helpful also.
Update: I need to do this specifically:
Hazel handles the recursion so for every file it finds:
- Store the
_-. <space> ,characters and store into a list or array
- loop through the list or array and
sed 's/^[ \t]*//;s/[ \t]*$//'to remove leading and trailing whitespace (from http://sed.sourceforge.net/sed1line.txt)
- convert the array to a comma separated string to feed into
tag -s $comma_separated_tags $filepath
I just don't know how to put that into a bash script format.