capturing multiple items (directories) in <curitem>

Discuss and share scripts and script files...
Post Reply
Joso
Posts: 95
Joined: 06 Apr 2010 14:13

capturing multiple items (directories) in <curitem>

Post 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.

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

Re: capturing multiple items (directories) in <curitem>

Post 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.
One of my scripts helped you out? Please donate via Paypal

Joso
Posts: 95
Joined: 06 Apr 2010 14:13

Re: capturing multiple items (directories) in <curitem>

Post 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.

Joso
Posts: 95
Joined: 06 Apr 2010 14:13

Re: capturing multiple items (directories) in <curitem>

Post 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??

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

Re: capturing multiple items (directories) in <curitem>

Post by highend »

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

Joso
Posts: 95
Joined: 06 Apr 2010 14:13

Re: capturing multiple items (directories) in <curitem>

Post 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?

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: capturing multiple items (directories) in <curitem>

Post 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

Joso
Posts: 95
Joined: 06 Apr 2010 14:13

Re: capturing multiple items (directories) in <curitem>

Post 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.

admin
Site Admin
Posts: 60563
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: capturing multiple items (directories) in <curitem>

Post 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.

admin
Site Admin
Posts: 60563
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: capturing multiple items (directories) in <curitem>

Post by admin »

I can now say that 2 billion characters is a theoretical value. The real limit is closer to 100 million.

Post Reply