Passing multiple folderitems to a shell helper app

I’m trying to implement a helper app, and I need to pass two folderitems and a command (string) to the helper so that it knows what files to work on and what to do.

I’ve pored over the ConsoleApplication docs, the Shell docs, and explored the WordCounter example app, but I’m missing some secret sauce…:frowning:

One puzzle is what format the paths should be in. The WordCounter GUI app sends the shell a ShellPath, but the WordCounter console app treats it as a Native Path. I can pass one path that way, though I don’t know why it works.

What I’d like to do is send the shell something like this:

MyHelperApp.ShellPath FirstFolderItem.ShellPath CommandToDoStr SecondFolderItem.ShellPath

However, this doesn’t work at all - there’s no way to separate the folder paths from each other and from the command because the folderitem paths include (escaped) spaces, so I can’t Split based on spaces. I tried separating the three arguments with tab characters, no luck.

Help!

Looks like colon is illegal for file names on both Mac and Windows. Could you use that as a separator?

What about setting an environment variable?
Or writing the string to a file and passing the filename.
Be careful about helper apps and command line parameters… There are limitations cause by spaces and there is a length limit a command line argument can be depending on the OS.

[quote=222412:@John McKernon]MyHelperApp.ShellPath FirstFolderItem.ShellPath CommandToDoStr SecondFolderItem.ShellPath

[/quote]

You are free to use any format for the parameters. Why not send them as Base64 ?

Base64 sounds like a great idea, I’ll give it (and maybe the colon suggestion) a try.

Thanks!

I like to use urlpaths personally as these cannot contain a space.

If you are using ShellPath, enclose them in quotes. Otherwise, use NativePath.

I wound up going with Michel’s suggestion to encode them as Base64. It works like a charm, and since all I’m passing is two paths I doubt they’ll ever go past the maximum command line length.

Thanks everyone!

[quote=222717:@John McKernon]I wound up going with Michel’s suggestion to encode them as Base64. It works like a charm, and since all I’m passing is two paths I doubt they’ll ever go past the maximum command line length.
[/quote]

In case anybody wanted to pass real numerous parameters, I would suggest using IPC, or put all the parameters in a file, and pass the name of it to the helper.