Create tag csv generates me a file that contains tags in this format
and Create Folder csv generates me a file that contains the ls output in this format:
My end goal is to export a table in this format:
This script is going to run periodically so that I can track the contents of a various directories, their tags, and create csv outputs that represents their contents/tags which I will link to in a master excel document
Any ideas on how I can move forward is much appreciated!
I always worry about listing a directory twice, at different times, and hoping you'll get the same result.
Since you are running a shell action for each item in the collection anyway, either get the folder name with a KM action (eg "Split Path") or do the whole lot in the shell script.
You're passing in a path, and the Unix-y way of getting the last part of the path is basename. You can combine that output with tab character (which saves you having to meet around with commas in the text), add the output from mdls and finish it all off with a newline character.
Easiest way to clean the mdls output is to delete the ()\n characters Obviously that won't work well if you have brackets and/or spaces in your tags, in which case you'll have to rethink (and will probably find it easier to do the processing in with KM actions).
Different echos behave differently, so we've invoked bash. And remember that, by default, the "Shell Script" action removes any trailing newlines -- we want one, so turn that off in the action's "Settings" cogwheel.
Here's a demo, using local variables instead of the globals you had above:
The pipe | redirects the output of the mdls command to be the standard input of tr.
You can find out about tr ("translate") using man tr in the Terminal (or by Googling the same). Usually it's used to swap characters in a string -- take standard input and any character in the first list is swapped for the corresponding one in the second, then output the new string. But the -d flag means "delete any and all characters in the following list" (and you only supply one list).
The list of characters to delete is between the double-quotes -- ( and ) are obvious, the last character is a typed space , and \n is the Unix new-line.
So "delete all the parentheses, spaces, and new-lines from the output of mdls and return the resulting string".