Background: I want to write an ahk script to extract content of selected folder to the parent level.
The first technical problem is solved (kind of): how to pass multiple arguments to script instead of call the script multiple times
Then I was blocked by the second also the final problem: how to use this file path array
The original script is here
srcFolder := A_Args[1]
targetFolder := substr(srcFolder, 1, instr(srcFolder, '\',, -1) - 1)
comobject('shell.application').namespace(targetFolder).movehere(srcFolder . '\*')
Why use shell.application? Because I want to use the fancy GUI of windows to handle file overwrite/readonly alert and so on.
It was called by context menu command and create an instance for every selected folder, the length of A_Args is always 1
Now our new A_Args is an array of selected folder path, they share a same parent folder (it's worth noting that it's possible not all children in this parent folder is selected)
When I try to update the script I found that movehere do support folderitems which is multiple folders as we need. However, I didn't found any "concat","additem" or similar method of folderitems, there's no way to concat all folderitems generate from each path of A_Args into one folderitems and pass it to movehere
If I call movehere for each of them, that will be the same as call multiple instance of the script...(the overwrite warning might be popup 99 times instead of showing a window displaying 99 overwrite entries)
The script I want to get:
srcFolders := A_Args ; path array
anySrcFolder := srcFolders[1] ; A_Args index start from 1
targetFolder := substr(anySrcFolder , 1, instr(anySrcFolder , '\',, -1) - 1)
srcFoldersComObj := MagicWayToConcatFolderItemsObject(srcFolders)
comobject('shell.application').namespace(targetFolder).movehere(srcFoldersComObj)