To Clipboard - > comma separated values

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
bugger
Posts: 47
Joined: 07 Apr 2008 19:03

To Clipboard - > comma separated values

Post by bugger »

Select a file(s) and then do a File -> To Clipboard -> Names, Bytes, Modified, Version.

This would be great for importing as CSV file, but the problem is that the Bytes field also use commas so a file with size 1,333,222 will have more commas than a file with 1,023 bytes, making for problems when importing into a spreadsheet.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: To Clipboard - > comma separated values

Post by highend »

Write a simple script that uses regexreplace() to replace the commas with dots?
One of my scripts helped you out? Please donate via Paypal

bugger
Posts: 47
Joined: 07 Apr 2008 19:03

Re: To Clipboard - > comma separated values

Post by bugger »

Ok, been a while since I played with scripts... Could just replace them with nothing and I'd be happy :)

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: To Clipboard - > comma separated values

Post by PeterH »

Switch to German?

Mine says: ..., 13.215.088 bytes, 11.01.2008 21:49:14, ...

i.e. it's dependent from localization.

How do you import? Comma-separated fields?

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: To Clipboard - > comma separated values

Post by highend »

Code: Select all

	$input = "<clipboard>";
	$output = "";
	foreach($line, "$input", "<crlf>"){
		$number = gettoken("$line", 2, ", ");
		$newnumber = replace("$number", ",", "");
		$newline = replace("$line", "$number", "$newnumber");
		$output = $output . $newline . <crlf>;
	}

	text $output;
Outputs this:

Code: Select all

Fabia_MonteCarlo_2011_06.pdf, 1402218 bytes, 06.12.2011 03:42:39
linuxmint-12-gnome-dvd-64bit.iso, 1066518528 bytes, 27.11.2011 20:06:36
RENESAS-USB3-Host-Driver-21280-setup.exe, 9742464 bytes, 11.11.2011 11:22:52, ver 2.1.28.0
From this:

Code: Select all

Fabia_MonteCarlo_2011_06.pdf, 1,402,218 bytes, 06.12.2011 03:42:39
linuxmint-12-gnome-dvd-64bit.iso, 1,066,518,528 bytes, 27.11.2011 20:06:36
RENESAS-USB3-Host-Driver-21280-setup.exe, 9,742,464 bytes, 11.11.2011 11:22:52, ver 2.1.28.0
Ack?
One of my scripts helped you out? Please donate via Paypal

bugger
Posts: 47
Joined: 07 Apr 2008 19:03

Re: To Clipboard - > comma separated values

Post by bugger »

Ack, I'd say so thanks :) Now is there a way to save $output back to the <clipboard>? So I don't have to bother with the dialog box.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: To Clipboard - > comma separated values

Post by highend »

Just replace

Code: Select all

text $output;
with

Code: Select all

copytext "$output";
One of my scripts helped you out? Please donate via Paypal

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: To Clipboard - > comma separated values

Post by TheQwerty »

Erm.. if you're going to use scripting why not just use report instead?

Code: Select all

"Name(s), Raw Bytes, Modified, FileVersion"
  // Get information on all items in list when nothing is selected.
  $useSelection = Get('CountSelected') > 0;
  $csv = Report("{Name}, {Size RAW}, {Modified}, {FileVersion}<crlf>", $useSelection);
  CopyText $csv;
Then you can fully control the formatting of the size and date, plus customize it for your needs.

bugger
Posts: 47
Joined: 07 Apr 2008 19:03

Re: To Clipboard - > comma separated values

Post by bugger »

Ah very nice TheQwerty, thanks much.

Post Reply