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

Copy file with wildcards

Status
Not open for further replies.

ghloid

IS-IT--Management
Mar 11, 2002
85
US
Hello all,

We're trying to set up a routine in Access that renames a file off of a floppy or other specified drive. The source filename changes with every new disk and therefore cannot be statically named in the code. We're trying to use the Copy File method to search for whatever file is found on the disk, then copy it down to another specified drive and folder location. This is the code we have so far:

Function CopyMPREFile()
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile "a:\*.dat", "J:\MPRE\MPREScores.txt"
End Function

This should work with the wildcard option as specified in the help text, yet it does not.

Any help you can offer is greatly appreciated.

THANKS!!
 
Hi Ghloid

It would seem to me that you are trying to specify your destination as a file rather than a folder, so it cant actually copy the *.DAT file to it. Suspect you will have to copy it to your folder and then rename it.

Someone with more experience than me with FileSystemObjects might be able to confirm this?

Asjeff
 
Sub moveIt()

Dim fso
Dim myFile

Set fso = CreateObject("Scripting.FileSystemObject")

Set myFolder = fso.GetFolder("C:\I_Temp\")

' Get the right file and rename it
For Each myFile In myFolder.Files
MsgBox (myFile.Name)

'If InStr(...

fso.MoveFile myFile, "C:\I_Temp\test.pdf"

DoEvents
Next

End Sub


search your *.dat with instr then ... move it

argg i lost 2 hours ...:-( with this fso.MOVE until i came up with the idea ...

regards Harry...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top