Page 1 of 1

Need script to wait for copy to finish

Posted: 03 Apr 2020 00:09
by Malarki
I need a CBT that will copy a whole optical disk X:\ to a new hard drive folder T:\WORD\X, then eject the optical disk. I have multiple optical drives that I want to use concurrently, so actually three of these CBTs each for a different drive letter X, Y, Z.

So far this line of code works fine for the concurrent copying:

Code: Select all

copyto "T:\WORD\X", "X:\", ,2, , 4, 1;
 //run "C:\_Util\NirSoft\NirCmd\nircmd.exe cdrom open x:"
The second line, currently disabled, calls a NirSoft util to eject the disk - BUT the script continues past "copyto" without waiting for its completion. So the disk gets ejected prematurely.

I chose "copyto" because I need the custom copy feature of creating a new folder on collisions, and the flag for keeping all dates is nice to have. But it may not be the best choice. And I'm considering a wait loop until the drive reads not-busy, but I don't see any script command that can determine that status.

So I have three questions:
1 - Is there a way to do the copyto that will wait for completion / or another copy method ??
2 - Is there a way to check optical drive status?
3 - Incidentally, is there a better way to eject the optical disk?

Re: Need script to wait for copy to finish

Posted: 03 Apr 2020 00:31
by highend
Use this before you copy command: setting "BackgroundFileOps", 0;

Re: Need script to wait for copy to finish

Posted: 06 Apr 2020 18:42
by Malarki
Disabling background ops breaks the concurrency. Meaning, then I can only launch one drive copy at a time. The whole point is to easily launch and complete several.

Re: Need script to wait for copy to finish

Posted: 06 Apr 2020 18:50
by highend
I don't see a real clever way to deal with this just by using XY's internal scripting (at least within a single instance).

What you could do:
- Let your code prepare <x> batch scripts, write them to disk (each of them will do one copy e.g. with a cli tool of your choice (maybe robocopy?) and the nirsoft command once it ends), and then execute them (with run).

- Or spawn multiple XY instances (from your main instance with a script) and feed all of them with the script from above (copyto, nirsoft, (evtl. trayballoon), exit XY instance) if you don't find a cli tool that does what you need...