Need script to wait for copy to finish

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Malarki
Posts: 109
Joined: 03 Dec 2019 02:51

Need script to wait for copy to finish

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

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: Need script to wait for copy to finish

Post by highend »

Use this before you copy command: setting "BackgroundFileOps", 0;
One of my scripts helped you out? Please donate via Paypal

Malarki
Posts: 109
Joined: 03 Dec 2019 02:51

Re: Need script to wait for copy to finish

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

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: Need script to wait for copy to finish

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

Post Reply