Page 1 of 1
Scripting: many single operations or few massive?
Posted: 03 Feb 2021 09:35
by eil
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?
Re: Scripting: many single operations or few massive?
Posted: 03 Feb 2021 09:50
by highend
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...
Re: Scripting: many single operations or few massive?
Posted: 03 Feb 2021 09:56
by eil
yep, that's second scenario, but is it really faster, that's what interests me?
Re: Scripting: many single operations or few massive?
Posted: 03 Feb 2021 10:04
by highend
Em?
You have 1000 files, 20% have the same yyyy-mm-dd, 20% less loops. Ofc this is faster, 20% less move commands^^
Re: Scripting: many single operations or few massive?
Posted: 03 Feb 2021 23:03
by eil
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).
Re: Scripting: many single operations or few massive?
Posted: 03 Feb 2021 23:22
by highend
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.
Re: Scripting: many single operations or few massive?
Posted: 04 Feb 2021 00:23
by eil
highend wrote: ↑03 Feb 2021 23:22
formatlist() with an exclusion filter
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?
Re: Scripting: many single operations or few massive?
Posted: 04 Feb 2021 00:27
by highend
The loop surrounds this
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
Use a
while(true) loop and the first statement is a
if (!$listOfItems) { break; }
Re: Scripting: many single operations or few massive?
Posted: 04 Feb 2021 00:31
by eil
thanks for hints!
Re: Scripting: many single operations or few massive?
Posted: 04 Feb 2021 12:23
by highend
search for all items with similar date > save in variable(to do smt)
You don't want to do that "search" everytime with a command like
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
If it is really only a flat structure,
report() with a template for modified date would work fine as well and does only contain the information that's necessary
Re: Scripting: many single operations or few massive?
Posted: 04 Feb 2021 13:26
by eil
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).
Re: Scripting: many single operations or few massive?
Posted: 04 Feb 2021 14:15
by highend
Where exactly is the problem now?
Pool of item(s) reducing loop.xys
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...