{allfilepath} - Changing separetor between each file

Hello,

When using {allfilepath} or {allfilepath|file}, is it possible to define the separator between each file other than spaces?

Regards,
Atalay TAN

Directory Opus 12.0.4 (Beta) x.64
Windows 10 Pro x64

It isn't, but a simple script can build up a list of filenames using any quoting or separator rules you might want.

Hello leo,

Could you please help about the script to build up a list of filenames "C:\Path\File1.txt|C:\Path\File2.pdf" - separated with pipe (|) symbol and whole list under single quote (") for example?

What do you want the script to do with the string after it builds it? Run a command with it, or something else?

If you give details of the command, we can provide the full solution in one go.

Thinking further: I'm guessing you don't want to run a command with the string because the | character would usually cause problems when running command-line programs. So we need to know what you want to do with it before we start, or we'll probably go down a dead-end.

Actually I am trying to send SMTP email with Swithmail (tbare.com/software/swithmail/) from command line.
My button is like this:
D:\Utilities\SwithMail\SwithMail.exe /s /x "D:\Utilities\SwithMail\smset.xml" /p1 "{file$}" /a ???
it takes server settings from xml file and after "/a" I need to specify attachments like this "C:\Path\File1.txt|C:\Path\File2.pdf" - separated with pipe (|) symbol. Iwould like it to attach my selected file or files to the e-mail. Is there a way to achieve that?

Best Regards,
Atalay TAN

This probably gets it done.
One question remains though, what do you expect to be within {file$} for the /p1 parameter?

[code]function OnClick(data){
var f=data.func, cmd=f.command, tab=f.sourcetab, sfiles=tab.selected_files, atts="";

for(var i=0;i<tab.selected_files.count;i++)
	atts+=sfiles(i).realpath+(i+1<sfiles.count?"|":"");

cmd.RunCommand('D:\Utilities\SwithMail\SwithMail.exe '+
	'/s /x "D:\Utilities\SwithMail\smset.xml" /p1 "{file$}" /a "'+atts+'"');	

}
[/code]

Weird, I wrote and thought I posted a script for this yesterday but it looks like I didn't post it.

/p1 looks like the email subject parameter from the SwithMail docs, so I think {file$} is expected to be the name of the first file.

I think this small change to tbone's script makes it do what you want with the /p1 {file$} part, although I have not tested it:

Script Type: JScript

[code]function OnClick(data){
var f=data.func, cmd=f.command, tab=f.sourcetab, sfiles=tab.selected_files, atts="";

for(var i=0;i<tab.selected_files.count;i++)
atts+=sfiles(i).realpath+(i+1<sfiles.count?"|":"");

cmd.RunCommand('D:\Utilities\SwithMail\SwithMail.exe '+
'/s /x "D:\Utilities\SwithMail\smset.xml" /p1 "' +
sfiles(i).name +
'" /a "'+atts+'"');
}[/code]

Here's the script I wrote yesterday, which I tested and which also does the /p1 {file$} part:

Script Type: JScript

[code]function OnClick(clickData)
{
if (clickData.func.sourcetab.selected.count > 0)
{
var cmd = clickData.func.command;
cmd.ClearFiles();
cmd.deselect = false; // Prevent automatic deselection

	var firstFileName = "";
	var fileList = "";

	for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
	{
		if (!eSel.item().is_dir)
		{
			if (fileList.length > 0)
				fileList += "|";
			else
				firstFileName = eSel.item().Name
			fileList += eSel.item().RealPath;
		}
	}

	var cmdLine = '"D:\\Utilities\\SwithMail\\SwithMail.exe" /s /x "D:\\Utilities\\SwithMail\\smset.xml" /p1 "' + firstFileName + '" /a "' + fileList + '"';

	//DOpus.Output(cmdLine);
	cmd.RunCommand(cmdLine);
}

}[/code]

Leo, consider having a break! o)

Hey guys I had a chance to test the script today in work and it works perfectly many thank to both of you.
Lastly can we make /p1 {file$} part to be the name of the all files not only the first file? These names can be separated with comma.

Not tested, but should work nonetheless. o)

[code]function OnClick(data){
var f=data.func, cmd=f.command, tab=f.sourcetab, sfiles=tab.selected_files, names="", atts="";

for(var i=0;i<tab.selected_files.count;i++){
atts+=sfiles(i).realpath+(i+1<sfiles.count?"|":"");
names+=sfiles(i).name+(i+1<sfiles.count?",":"");
}

cmd.RunCommand('D:\Utilities\SwithMail\SwithMail.exe '+
'/s /x "D:\Utilities\SwithMail\smset.xml" ' +
'/p1 "' + names + '" ' +
'/a "'+atts+'"');
}[/code]

Hello tbone, I couldn't make it work. I think "}" before cmd.RunCommand should be removed. It didn't work even if
I remove it.

Maybe the backslashes in the command just need to be escaped?

Yes! it is working fine now thank you:

[code]function OnClick(data){
var f=data.func, cmd=f.command, tab=f.sourcetab, sfiles=tab.selected_files, names="", atts="";

for(var i=0;i<tab.selected_files.count;i++){
atts+=sfiles(i).realpath+(i+1<sfiles.count?"|":"");
names+=sfiles(i).name+(i+1<sfiles.count?",":"");
}
cmd.RunCommand('D:\Utilities\SwithMail\SwithMail.exe '+
'/s /x "D:\Utilities\SwithMail\smset.xml" ' +
'/p1 "' + names + '" ' +
'/a "'+atts+'"');
}[/code]

Good! Do you have blanks in your paths somewhere, looking at this again, I think these could lead to some difficulties.

Yes there are blanks in some paths but I tested and it worked. For example I could managed to e-mail below file with 3 other files successfully.
"D:\EKOS\PRJ\AFŞİN-ELBİSTAN\RÖLE İHALESİ\2012-180825_EÜAŞ-Afşin Elbistan B Rölesi Alımı ihalesi\Afşin_İhale dosyası alınması hk..doc"

Do you think it can be a problem in some situations?

I was wrong, I rethinked this and it should be fine! o)
I was in a hurry around noon because of an appointment and my brain had already left the house. o)

But it is possible modify this script to use it with hashfile?

I wanted to send the full path of all selected files

The command line is

HashMyFiles.exe /files "c:\temp\file.zip" "c:\temp\1234.exe" "c:\blablabla\Hello.exe" ....

and optionally add this (/stext ) to save the file directly.

HashMyFiles.exe /files "c:\temp\file.zip" "c:\temp\1234.exe" "c:\temp\Hello.exe" /stext

Thanks

I'm actually working on a script to do hashing to a file based on Opus's built in hashing functions, I'll be sharing it soon!

Script for hashing is here: Tool: Hash file creation & validation

[quote="Birba"]I wanted to send the full path of all selected files

The command line is

HashMyFiles.exe /files "c:\temp\file.zip" "c:\temp\1234.exe" "c:\blablabla\Hello.exe" ....

and optionally add this (/stext ) to save the file directly.

HashMyFiles.exe /files "c:\temp\file.zip" "c:\temp\1234.exe" "c:\temp\Hello.exe" /stext [/quote]

I don't think you need a script for that. {allfilepath$} will get you all the selected file paths on one line, separated by spaces. That's what it does by default.

(Tenebrous's script may still be of interest, since it lets you generate the hash file without any external tools.)