[Solved] In what order do files get joined?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
iycgtptyarvg
Posts: 222
Joined: 10 Jun 2008 15:40
Location: Netherlands

[Solved] In what order do files get joined?

Post by iycgtptyarvg »

I have this script (I think I got it from someone on this forum):

Code: Select all

//Combine selected files in order
"Concatenate Files"
	$itemCount = get("CountSelected");
	if ($itemCount < 2){
		msg "Please select two or more files to concatenate.", 0 + 48;
	}
	else {
		//No modifier keys pressed - use defaults
		$outputFileExt = getpathcomponent("<selitem>", "ext");
		
		//Initialise variables used in loop
		$outputFilePath = <curpath> . "\" . <date yyyy-mm-dd-hh-mm-ss> . ".$outputFileExt";
		$index = 0;

		//Process files
		foreach($token, <get selecteditemspathnames |>) {
			$index = $index + 1;
			$fileContent = readfile("$token");
			writefile("$outputFilePath", $fileContent, "a");
		}
		status "Concatenated file generation complete - $outputFilePath";
	}
I'm afraid to use this when the order of joining matters. Is there a GUARANTEED order? For instance, always alphabetically, or always in the order how it is displayed in the file list, or maybe depending on how you drag select the files (top to bottom, or bottom to top), or maybe in which order you <CTRL>-clicked them?

Does someone know 100% sure?
Last edited by iycgtptyarvg on 05 Mar 2020 13:41, edited 1 time in total.
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: In what order do files get joined?

Post by highend »

There is no guaranteed order but you are free to create it yourself by e.g using
an inputselect with 16+512 flags...
One of my scripts helped you out? Please donate via Paypal

iycgtptyarvg
Posts: 222
Joined: 10 Jun 2008 15:40
Location: Netherlands

Re: In what order do files get joined?

Post by iycgtptyarvg »

Unfortunately, I don't know how to do that.
Could you please alter the script to have the guaranteed order HOW IT IS DISPLAYED IN THE FILES LIST?
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: In what order do files get joined?

Post by highend »

Just to make this 100% sure, you want the selected items in that order how the current list displays them.

E.g. these 4 files are selected and the list is sorted by name ascendingly:

Code: Select all

Dbg.pbi
Math.pbi
Process.pbi
ScanDir.pbi
You would join them in that order.

If you would now change the sort order for the name column from ascending to descending and the displayed items would change too:

Code: Select all

ScanDir.pbi
Process.pbi
Math.pbi
external
Dbg.pbi
You would want them to be joined in this new order regardless how they were selected? In that case there is no need for a change,
<get selecteditemspathnames |> uses the displayed order from the list...

It would be different if e.g. <drop> would be used...
One of my scripts helped you out? Please donate via Paypal

iycgtptyarvg
Posts: 222
Joined: 10 Jun 2008 15:40
Location: Netherlands

Re: In what order do files get joined?

Post by iycgtptyarvg »

Ok, so to make this 100% clear.

How it is now will join in VISIBLE ORDER, regardless how I selected it and which is the 'focused' item?
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: In what order do files get joined?

Post by highend »

Yep
One of my scripts helped you out? Please donate via Paypal

iycgtptyarvg
Posts: 222
Joined: 10 Jun 2008 15:40
Location: Netherlands

Re: [Solved] In what order do files get joined?

Post by iycgtptyarvg »

Thank you, thank you, thank you.

I marked it [Solved].
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.

Post Reply