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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving PDF's

Status
Not open for further replies.

CooterBrown

IS-IT--Management
Aug 17, 2001
125
0
0
US
I'm trying to move a group of PDF's from one folder/staging area to another folder for processing. There are going to be about 1000 400KB pdf's. What is the most efficient way to do this?
Here is what I have tried but it is slow...
------------------------------------------------------------
If mFs.FolderExists(FolderSpec) Then
Set mFolder = mFs.GetFolder(FolderSpec)
On Error Resume Next
For Each mFile In mFolder.Files
space = InStr(1, mFile.DateCreated, " ")
TimePrinted = mFile.DateCreated
DatePrinted = Trim(Mid(mFile.DateCreated, 1, space))
CompareDate = Month(wrkQueryDate) & "/" & Day(wrkQueryDate) + 1 & "/" & Year(wrkQueryDate) & " 12:00:00 AM"
CompareHours = DateDiff("h", TimePrinted, CompareDate)
If (12 > CompareHours) And (CompareHours > -12) Then
MoveTo = (Environment & "\" & mFile.Name)
Debug.Print MoveTo
mFile.Copy MoveTo, True

mFile.Delete
Kill (mFile)
' - what is the diff between .delete and kill()?

i = i + 1
End If
Next
End If
 
Some maths to clean up
TimePrinted = Cdbl(mFile.DateCreated)
DatePrinted = Int(mFile.DateCreated)
CompareDate = DatePrinted + 1
CompareHours = CompareDate - TimePrinted

Then

CompareHours = Int(mFile.DateCreated)+ 1 - Cdbl(mFile.DateCreated)

Also
12hours > CompareHours) And (CompareHours > -12hours) =>
-12hours<CompareHours<12hours => |CompareHours|<12 hours =>
|CompareHours| < 0.5

Plus
Copy + Delete = Move

So all this in combination...

If Abs(Int(mFile.DateCreated)+ 1 - Cdbl(mFile.DateCreated)) < 0.5 then
mFile.Move Environment & "\" & mFile.Name
i = i +1
End If
 
>' - what is the diff between .delete and kill()?

Not a lot, really.

There are some differences in the mechanics, that;s all

.delete is a method of the Microsoft Scripting Runtime library's File class that deletes the file that the class represents.

Kill is a method of VB's built-in FileSystem class that deletes a named file. Ah, you say, but I'm passing it an object (mFile), not a named file. Well no. You are encountering the default property effect. The default property of the File class is .Path, so what you are actually doing is passing the fully qualified path of the file represented by mFile to the Kill command
 
So other than my sloppy math, this is the most efficient way to move a batch of PDF's from one directory to another?
The process seems to be hanging up at the "mFile.Copy MoveTo, True" command.

Could I do it as a batch process behind the scene somehow so as not to tie up the users PC?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top