Total Size Selector 1.1 - November 19, 2013

Discuss and share scripts and script files...
Enternal
Posts: 1175
Joined: 10 Jan 2012 18:26

Total Size Selector 1.1 - November 19, 2013

Post by Enternal »

I saw this feature in another tool and thought it might be useful. What it does is you input the maximum total file/folder sizes that you need and the script will then automatically randomly select files/folders that will add as close as it can to that maximum size that you specified. So what's the use? So you have a computer that is not connected to anything (internet or network) and you need to transfer files from it but you only have a 128 MB flash drive. You could simply just randomly select things and see if it does not go over 128 MB and then move it. But that would take a lot of time. Instead:

1. Run the Script
2. Select Files/Folders or Files Only
3. Select Unit Size (B, KB, MB, GB)
4. Input Size (Example: 128)

The script will then automatically choose the items that add up to as close as it can get to 128 MB. You then move it to the flash drive, transfer the items to another computer, and then repeat the cycle. Also thanks to highend and TheQwerty!

Like I said, you probably don't need to use it very often but it might be useful.

NOTE: The Files/Folders Mode can take a very long time when processing deeply nested folders. Be careful where you use that mode. For example, don't use it at the root of your system drive.

Update: Version 1.1 on November 19, 2013
* Fix a small loop bug.
* Will now pop up only 1 dialog. Allow input of both value and unit. So "256 B", "1 KB", "5 MB", "1 GB", or "1 TB". Also case does not matter for the unit.
Note: All units are in multiple of Bytes and NOT Bits.
* Thanks to Don's new change in Format & FormatBytes scripting commands, all input that uses "," or "." as decimal separators now work! So:
1.5 KB or 1,5 KB will work perfectly!
TotalSizeSelector.xys
Capture.PNG
To see the attached files, you need to log into the forum.
Last edited by Enternal on 20 Nov 2013 00:15, edited 4 times in total.

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

Re: Total Size Selector 1.0 - November 16, 2013

Post by highend »

I'd use only one input box where the user adds "b,k,mb,gb,tb" after the value.
Parse the input and split the value from the size description.

Alternatively use html, you could do the file / folder selection, the size description and the value
in one single window. Less clicks, <Tab> works.

Btw, a value like "8.0" doesn't work but a comma is processed correctly.
One of my scripts helped you out? Please donate via Paypal

Enternal
Posts: 1175
Joined: 10 Jan 2012 18:26

Re: Total Size Selector 1.0 - November 16, 2013

Post by Enternal »

highend wrote:I'd use only one input box where the user adds "b,k,mb,gb,tb" after the value.
Parse the input and split the value from the size description.
Yes that would make it easier. I'm going to work on it again later tonight or tomorrow.
highend wrote:Alternatively use html, you could do the file / folder selection, the size description and the value
in one single window. Less clicks, <Tab> works.
Woah somehow that sounds a lot of work. I kind of like the idea as it is right now though since it's simple and it's not used frequently I think.
highend wrote:Btw, a value like "8.0" doesn't work but a comma is processed correctly.
It doesn't work?! That's odd. It works for me so I think it has to do with the FormatBytes() since apparently the system format settings has an effect on it. Depending on the system, it might be a comma or a period. I will read more about it and see if I can prevent it from breaking.

Edit: Just to be sure, your locale is German right? So how do you represent thousands places? How about decimal places? Still playing for the format() command to see if I can do some quick changes before actually using formatbytes().

According to: http://msdn.microsoft.com/en-us/goglobal/bb688127.aspx
In the United States, this character is a period (.). In Germany, it is a
comma (,). Thus one thousand twenty-five and seven tenths is displayed
as 1,025.7 in the United States and 1.025,7 in Germany.

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Total Size Selector 1.0 - November 16, 2013

Post by yusef88 »

hi Enternal
after some tests; it selects items with size more than i've chosen and this happens only when using option files/folders.
another note: script make xy not responding when using it on huge lists also with option files/folders

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Total Size Selector 1.0 - November 16, 2013

Post by yusef88 »

There is a difference between the size of selected files that shown XY status bar and win explorer

update:this is because folder size doesn't calculated by default in XY status bar
To see the attached files, you need to log into the forum.

Enternal
Posts: 1175
Joined: 10 Jan 2012 18:26

Re: Total Size Selector 1.0 - November 16, 2013

Post by Enternal »

@ yusef88
Yeah by default XYplorer does not calculate the folders by default. However, did the selection match up with what you input? What was your input?

Also Files/Folders scan can "freeze" XYplorer because it has to calculate the folder sizes and for heavily nested and large folders, it will take a long time. Therefore you have to use it with care.

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Total Size Selector 1.0 - November 16, 2013

Post by yusef88 »

input 2 GB
selected 2.55 GB
To see the attached files, you need to log into the forum.

Enternal
Posts: 1175
Joined: 10 Jan 2012 18:26

Re: Total Size Selector 1.0 - November 16, 2013

Post by Enternal »

Can you try it with just "Files Only"? So that I can see which of the methods I used were incorrect. Use the same 2 GB if you can.

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Total Size Selector 1.0 - November 16, 2013

Post by yusef88 »

Files Only works fine

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

Re: Total Size Selector 1.0 - November 16, 2013

Post by highend »

@Enternal

Why don't you replace

Code: Select all

		$FolderList = "";
		$ListofItems = Report("{FullName}|", 0);
		$ListofItems = FormatList($ListofItems, e, "|");
		ForEach($Folder, $ListofItems, "|", , "not Valid Items!") {
			If Exists($Folder) == 2 {
				$FolderList = $FolderList."|".$Folder."|";
				$FolderList = FormatList($FolderList, e, "|");
			}
		}
		$ListofItems = ReplaceList($ListofItems,$FolderList,"","|");
		$ListofItems = FormatList($ListofItems, e, "|");
with

Code: Select all

$ListofItems = FolderReport("files","r",,,,"|");
I see no reason to get a list including folders and to strip them out afterwards when you can get everything in a single function call.
One of my scripts helped you out? Please donate via Paypal

Enternal
Posts: 1175
Joined: 10 Jan 2012 18:26

Re: Total Size Selector 1.0 - November 16, 2013

Post by Enternal »

@ highend
The reason why I did it that way was because... :oops: I did not read the function correctly. Thanks! That makes it the code much more understandable now and streamlined. Also were you able to figure out the formatting issues. I could not see an issue with the formatting because it should work depending on the locale.

@ yusef88
Ok. I simplified a part of the code. Can you see if it works now? Apparently I made it more difficult than it had too.
To see the attached files, you need to log into the forum.

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Total Size Selector 1.0 - November 16, 2013

Post by yusef88 »

it ls better now, well done!

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

Re: Total Size Selector 1.0 - November 16, 2013

Post by highend »

Also were you able to figure out the formatting issues. I could not see an issue with the formatting because it should work depending on the locale.
It's your script, I just reported a bug ;)

It still doesn't work on a system with a german locale.

E.g.:
Files
MB
300.0

It will select all files in the current folder (around 850MB)...
One of my scripts helped you out? Please donate via Paypal

Enternal
Posts: 1175
Joined: 10 Jan 2012 18:26

Re: Total Size Selector 1.0 - November 16, 2013

Post by Enternal »

@yusef88
Yeah! :biggrin:
highend wrote:
Also were you able to figure out the formatting issues. I could not see an issue with the formatting because it should work depending on the locale.
It's your script, I just reported a bug ;)

It still doesn't work on a system with a german locale.

E.g.:
Files
MB
300.0

It will select all files in the current folder (around 850MB)...
This is completely stumping me right now. I don't think it's a bug but since you're on a German locale, it expects that your thousand separator to be a "." while the decimal separator to be the "," which is opposite of the usual 1,271.05

US: 1,271.95
German: 1.271,95

Still can't figure out how to make it local independent yet. Also it seems Don and several others are still trying to solve some formatting issues with scripting on German locale.

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

Re: Total Size Selector 1.0 - November 16, 2013

Post by PeterH »

Enternal wrote:@yusef88
Yeah! :biggrin:
highend wrote:
Also were you able to figure out the formatting issues. I could not see an issue with the formatting because it should work depending on the locale.
It's your script, I just reported a bug ;)

It still doesn't work on a system with a german locale.

E.g.:
Files
MB
300.0

It will select all files in the current folder (around 850MB)...
This is completely stumping me right now. I don't think it's a bug but since you're on a German locale, it expects that your thousand separator to be a "." while the decimal separator to be the "," which is opposite of the usual 1,271.05

US: 1,271.95
German: 1.271,95

Still can't figure out how to make it local independent yet. Also it seems Don and several others are still trying to solve some formatting issues with scripting on German locale.
OK: you *could* specify 127195/100 - but that's not *very* nice.

You can wait a bit - I understood Don will try to help for this problem of non-US locale.

Post Reply