Copy move destination in script

I have thousands of PDF files which I wish to thumbnail. If I dump them into a lister it overwhelms Mystic thumbs and 60 per cent never thumbnail (I have reported to the problem to Mystic Thumbs, but an growing old and grumpy waiting for a response) and so I thought I would try a little DIY and come up with the following development script:

Function OnClick(ByRef clickData)
 StrDir = "D:\Rog" '(Temporary holding directory)
 Desdir = "E\Imaging\Stock Images\EPS Files\E\"  'Permanent destination for thumb-nailed PDF files
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set objFiles = fso.GetFolder(strDir).Files  
    lngFileCount = objFiles.Count
   ' MsgBox lngFileCount     'Total number of files
    Set folderEnum = DOpus.FSUtil.ReadDir(StrDir, False)
	Do While (Not folderEnum.Complete)
		Set folderItem = folderEnum.Next
		DOpus.Output folderItem
	    cmdline = "COPY FILE """ & folderitem & """ MOVE TO """ & Desdir & """"
'				DOpus.Output folderItem
'		DOpus.Output cmdline
	    clickData.func.command.RunCommand(cmdline)
DOpus.Delay 2500
	Loop
	msgbox "TASK COMPLETED"
End Function

The idea is that I place the PDF files in a folder and move them one at a time with 2.5 sec delay into the folder where they are permanently to reside.

It works a treat - but only if I have a dual lister with the temporary folder on the right and the permanent folder on the left.

I want to run the macro in the backgound, but when I do I get an error message saying I am trying to copy the file on top of itself.

There is obviously something bear of little brain is missing here. Can anyone offer sage words of advice?

**

Try:

Function OnClick(ByRef clickData)
	StrDir = "D:\Rog" '(Temporary holding directory)
	Desdir = "E\Imaging\Stock Images\EPS Files\E\"  'Permanent destination for thumb-nailed PDF files
	Set cmd = clickData.func.command ' <-- NEW LINE
	cmd.ClearFiles                   ' <-- NEW LINE
	Set folderEnum = DOpus.FSUtil.ReadDir(StrDir, False)
	Do While (Not folderEnum.Complete)
		Set folderItem = folderEnum.Next
'		DOpus.Output folderItem
		cmdline = "COPY FILE """ & folderitem & """ MOVE TO """ & Desdir & """"
'		DOpus.Output folderItem
'		DOpus.Output cmdline
		cmd.RunCommand(cmdline) ' <-- MODIFIED LINE
		DOpus.Delay 2500
	Loop
	msgbox "TASK COMPLETED"
End Function

You may also find that you can avoid the Mystic Thumbs problem by reducing the number of thumbnail threads to 1.

Leo,
Many thanks. Both your suggestions work a treat.

Reducing the thumbnail threads eliminates the problem at source - as it were - rendering my solution unnecessary.

I really appreciate your prompt response