Let's say i have 1000 files to move to folders by their dates. which variant will be faster?
- if script checks each files and moves that one to proper folder
- if script gathers a stack of files with similar date and then moves whole stack to proper folder
..or there is no difference?
Scripting: many single operations or few massive?
-
eil
- Posts: 1898
- Joined: 13 Jan 2011 19:44
Scripting: many single operations or few massive?
Win 7 SP1 x64 100% 1366x768|1900x1080
-
highend
- Posts: 15012
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Scripting: many single operations or few massive?
One command to gather every necessary information, loop over it and on each loop group items, move them and remove them from the pool -> Only as many loops as absolutely required...
One of my scripts helped you out? Please donate via Paypal
-
eil
- Posts: 1898
- Joined: 13 Jan 2011 19:44
Re: Scripting: many single operations or few massive?
yep, that's second scenario, but is it really faster, that's what interests me?
Win 7 SP1 x64 100% 1366x768|1900x1080
-
highend
- Posts: 15012
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Scripting: many single operations or few massive?
Em?
You have 1000 files, 20% have the same yyyy-mm-dd, 20% less loops. Ofc this is faster, 20% less move commands^^
You have 1000 files, 20% have the same yyyy-mm-dd, 20% less loops. Ofc this is faster, 20% less move commands^^
One of my scripts helped you out? Please donate via Paypal
-
eil
- Posts: 1898
- Joined: 13 Jan 2011 19:44
Re: Scripting: many single operations or few massive?
noob question again: what is the best algorithm for such gathering? i just can't understand how to compare items after they are gathered in variable.(or maybe it's wrong way and there is even better than comparing them one-by-one, say to get all items of similar date).
Win 7 SP1 x64 100% 1366x768|1900x1080
-
highend
- Posts: 15012
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Scripting: many single operations or few massive?
formatlist() with an exclusion filter or regexreplace(), that are the two possibilites. I've used the latter mostly but XY got some speed improvements for really large datasets so that formatlist() is a viable option nowadays.
One of my scripts helped you out? Please donate via Paypal
-
eil
- Posts: 1898
- Joined: 13 Jan 2011 19:44
Re: Scripting: many single operations or few massive?
get list of items > get date of first/any item > search for all items with similar date > save in variable(to do smt) > formatlist() with filter-exclude of those found > loop with "new smaller" list of items = smt like this?
Win 7 SP1 x64 100% 1366x768|1900x1080
-
highend
- Posts: 15012
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Scripting: many single operations or few massive?
The loop surrounds this
Use a
Code: Select all
get date of first/any item > search for all items with similar date > save in variable(to do smt) > formatlist() with filter-exclude of those found
while(true) loop and the first statement is a if (!$listOfItems) { break; }One of my scripts helped you out? Please donate via Paypal
-
eil
- Posts: 1898
- Joined: 13 Jan 2011 19:44
Re: Scripting: many single operations or few massive?
thanks for hints!
Win 7 SP1 x64 100% 1366x768|1900x1080
-
highend
- Posts: 15012
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Scripting: many single operations or few massive?
You don't want to do that "search" everytime with a command likesearch for all items with similar date > save in variable(to do smt)
quicksearch(), do you?You gather that information once before the loop and assign it to the "pool" variable.
Like:
Code: Select all
$pool = quicksearch(, "/fn", , "sm"); // Either only "m" or "sm" to see the progress as well
report() with a template for modified date would work fine as well and does only contain the information that's necessaryOne of my scripts helped you out? Please donate via Paypal
-
eil
- Posts: 1898
- Joined: 13 Jan 2011 19:44
Re: Scripting: many single operations or few massive?
well basically with initial question i wanted to understand if i can modify script i was trying to do(or better to say you did) in this topic= viewtopic.php?f=7&t=21686
recently i used a lot, and as it checks file-by-file, say 16Gb of images took me ~15min of time to move them to proper date-folders. that's why i'm searching for a way to make it faster(gather same date items and then move them, seems like most there can be done).
recently i used a lot, and as it checks file-by-file, say 16Gb of images took me ~15min of time to move them to proper date-folders. that's why i'm searching for a way to make it faster(gather same date items and then move them, seems like most there can be done).
Win 7 SP1 x64 100% 1366x768|1900x1080
-
highend
- Posts: 15012
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Scripting: many single operations or few massive?
Where exactly is the problem now?
Why did I use a
Something that
Why did I use a
regexmatches() to find all files with the same date? Because I don't want to match those that have a yyyy-mm-dd date in their path or name...Something that
formatlist() can't do for me...To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club