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

copy file to a folder

Status
Not open for further replies.

encata

MIS
Apr 9, 2002
100
ET
I have scheduled backup file (BK.bkf) overwritten daily.I want to copy this backup file to a folder. The folder is going to hold the daily backup files with different names,so that i will have 30 files at the end of the month.

can you help me with VB script or any other scripts to automate the job.

Thanks

Why you worry? Life is too short to worry.
 
You will probably have to use SHFileOperation API from a VB Front end. You also have to use some sort of a timer to make it repetitive.

It also uses an arugument which is of type SHFILEOPSTRUCT.

Let me see if i can get those declarations for you.. these should get you started..

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Declarations for you..

Code:
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Type SHFILEOPSTRUCT
    hWnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAnyOperationsAborted As Boolean
    hNameMappings As Long
    lpszProgressTitle As String
End Type

PS: If you want a simpler solution, you can also use VBs own 'Name' function. This is how you will use it..

Code:
Name "SourceFilePath\SourceFileName" As "DestinationFilePath\DestinationFileName"

You will have to create the logic to make the filenames unique.

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Er ... why would we need to resort to SHFileOperation? There's nothing in the original post that suggests that this would be necessary. The built-in FileCopy method, or, if you need wild cards, the FileSystemObject's CopyFile method would seem to be sufficient
 
I see from your original question
encata said:
can you help me with VB script or any other scripts to automate the job.
that you mention VBScript. Although many aspects of VBScript are similar to VB 5/6, there are also many differences. If this is actually a VBScript question, then try the VBSCript forum, forum729. If you are going to use VB6, then the Filecopy option should do it for you

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
>VBs own 'Name' function

Warning: that is the equivalent of moving the file, not copying it
 
Hi everybody

Thanks for the reply

I am not a programmer, but have some knowledge of VB6 i can write simpler logics.

This time i wanted a script or vb code that meets my senario.

johnwm,
the vb script forum link is talking about Mobiles

Why you worry? Life is too short to worry.
 
I think jonhwm meant
forum329


----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
----------------------------------------
No D, just plank - and its not my fault
 
Ok thanks
I moved the post to vb script forum forum329


Why you worry? Life is too short to worry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top