Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moveFile is moving all but the last file

Status
Not open for further replies.

JV28132

Programmer
Apr 19, 2010
11
US
I have a script that is running and working fine. but it is using

strStoragePath2 = "C:\Reike\Email\"
StrFilePath = "C:\AC\Work\*.pdf"
objFSO.MoveFile StrFilePath, strStoragePath2

The problem is that if the folder has 10 files the first 9 are being moved and the last file is not. Has anyone ever had this problem before?

I tried changing the above to the following:

Dim colFiles
For Each objFile In colFiles
If LCase(Right(objFile.Name, 3)) = "pdf" Then
objFSO.Copyfile objFile, (strStoragePath3)
objFSO.DeleteFile objFile, True
End If
Next

But this alternative is not working at all. So I'm back to the original... moveFile. any suggestions? Its odd that all move with the exception of the last one.


 
the first 9 are being moved and the last file is not
Does the last file have the very same extension ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How about trying to ID the files by type instead of extension.

Code:
For Each objFile In colFiles
	If objFile.Type = "Adobe Acrobat Document" Then
	   objFSO.Copyfile objFile, (strStoragePath3)
	   objFSO.DeleteFile objFile, True
	End If
Next

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
yes the files all have the same file extension.

Thank you for the idea for file type - didn't know that was possible. I'll give it a try and let you know. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top