Page 1 of 1
capturing multiple items (directories) in <curitem>
Posted: 31 Jul 2011 19:09
by Joso
I have 100 (or 1000) directories that each contain files to be moved up one level (to the current path) - so ...
Code: Select all
moveto "<curpath>", "<curitem>\*.*";
does the trick - BUT - how can I select all 100 directories and move their contents at one time (instead of running the script 100 times)? Is there some method to get multiple items into the <curitem> variable? Thanks.
Re: capturing multiple items (directories) in <curitem>
Posted: 31 Jul 2011 23:53
by highend
Joso wrote:Is there some method to get multiple items into the <curitem> variable? Thanks.
Code: Select all
$SelectedItems = get("SelectedItemsPathNames", "|");
and then you can use a foreach loop to put them all one level up (the selecting of the different folders has to be done manually).
If the folder names share specific parts of a common name (and all the other folders don't do) you can have a look at strpos() and selectitems() to avoid adding them all by hand.
Re: capturing multiple items (directories) in <curitem>
Posted: 01 Aug 2011 01:02
by Joso
thanks - just what I was looking for. The completed snippit is:
Code: Select all
//move contents of each selected dir up one level
foreach($token, <get selecteditemspathnames |>) {
moveto "<curpath>", "$token\*.*";
}
the <curitem> variable was a dead end. Thanks for steering me in the right direction.
Re: capturing multiple items (directories) in <curitem>
Posted: 02 Aug 2011 02:47
by Joso
Hmm - odd behavior with this script. I had a directory with 96 subdirs - each one had a fairly long name, maybe 70 characters. When I selected all 96 subdirs and tried to move their contents up a level, the script would end after about 20 - 25 loops (no error - just exit). Maybe there's a limit on the string the get function will take??
Re: capturing multiple items (directories) in <curitem>
Posted: 02 Aug 2011 03:13
by highend
Re: capturing multiple items (directories) in <curitem>
Posted: 02 Aug 2011 14:45
by Joso
I seem to bump into old size/memory limits all the time with the PC. - so the size limit on the "get" string is 2,000 or 8,000 or so depending on the code page? - Does this limit apply to any string variable?
Re: capturing multiple items (directories) in <curitem>
Posted: 02 Aug 2011 16:18
by Stefan
Joso wrote:I seem to bump into old size/memory limits all the time with the PC. - so the size limit on the "get" string is 2,000 or 8,000 or so depending on the code page? - Does this limit apply to any string variable?
There is no DOS command line involved by using XY script.
Joso wrote:I have 100 directories that each contain files to be moved up one level (to the current path)
What do you need anyway? Maybe i got i wrong.
You have sub-folders like:
X:\MainFolder\001\files1
X:\MainFolder\002\files2
X:\MainFolder\003\files3
...
X:\MainFolder\999\files9
and want to move all files one level up to "MainFolder" ?
X:\MainFolder\files1
X:\MainFolder\files2
X:\MainFolder\files3
X:\MainFolder\files9
Then that code should do it.
- -
Or are there even sub-sub-folders?
X:\MainFolder\Level2\999\files
X:\MainFolder\Level2\Level3\999\files
Re: capturing multiple items (directories) in <curitem>
Posted: 02 Aug 2011 17:38
by Joso
no - you've got the concept right - and the script works just fine as long as I don't select too many directories. As I mentioned, each of the direcectories had a name about 70 chars long - so the get string would be maybe 7000 characters with all of them selected at one time. - That's when the script breaks down. Works fine with maybe 20 directories selected. I think there must be a dos or windows related size limit on the length of the get string. Maybe Don would know.
Re: capturing multiple items (directories) in <curitem>
Posted: 23 Aug 2011 14:27
by admin
Joso wrote:no - you've got the concept right - and the script works just fine as long as I don't select too many directories. As I mentioned, each of the direcectories had a name about 70 chars long - so the get string would be maybe 7000 characters with all of them selected at one time. - That's when the script breaks down. Works fine with maybe 20 directories selected. I think there must be a dos or windows related size limit on the length of the get string. Maybe Don would know.
The limit is around 2 billion characters.
Try to disable background processing. It's sometimes causing unexpected behavior with scripts.
Re: capturing multiple items (directories) in <curitem>
Posted: 02 Nov 2021 10:05
by admin
I can now say that 2 billion characters is a theoretical value. The real limit is closer to 100 million.