|
-
Jul 28th, 2000, 09:15 PM
#1
Thread Starter
Hyperactive Member
I have a program that copies files in a directory and saves them into a backup folder. There are multiple files that the program (the program that creates the files I backup) makes when they save. I need to be able to access all of the files to copy... They enter the name of the save...and that can be used to get the files names...but not the extension.
How would i make the filecopy function copy their text (for the files names) and make it copy all extensions that share the same name?
FileCopy "C:\Windows\Filesname.*", "D:\backup\Filesname.*"
Would something like that work?
-
Jul 28th, 2000, 11:21 PM
#2
Fanatic Member
you could use a filebox with a filter and run down the list
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Jul 28th, 2000, 11:28 PM
#3
transcendental analytic
You could use Dir function and return all files of that extension, and you can use wildchars too, then copy each of them
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 28th, 2000, 11:45 PM
#4
Thread Starter
Hyperactive Member
can you guys give me an example...
And I there are other files in the directory...so I cant copy all files in the dir.
-
Jul 29th, 2000, 12:26 AM
#5
transcendental analytic
Code:
Dim A as string
A=Dir(Source)
Do
FileCopy A, Destination
A=Dir
Loop While len(a)
Where you put Source String to "C:\Windows\Filesname.*" and Destination String to "D:\backup"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 29th, 2000, 01:06 AM
#6
Thread Starter
Hyperactive Member
that didn't work :-((((((((((((
-
Jul 29th, 2000, 03:56 AM
#7
Fanatic Member
Drop the following into a module.
Code:
Option Explicit
Sub Main()
'Method1
Call p_CopyMethod1("C:\Internet Download\*.*", "C:\Unzip Area")
'Method2
Call p_CopyMethod2("C:\Internet Download", "C:\Unzip Area")
End Sub
Sub p_CopyMethod1(str_Source As String, str_Destination As String)
Dim v_FileSystemObject As Object
Set v_FileSystemObject = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
'PURPOSE:Copy all files in current directory
v_FileSystemObject.CopyFile str_Source, str_Destination, True
'PURPOSE:Copy all sub directories in current directory
'v_FileSystemObject.CopyFolder str_Source, str_Destination, True
Set v_FileSystemObject = Nothing
End Sub
Sub p_CopyMethod2(str_Source As String, str_Destination As String)
'PURPOSE:Check if user inputted a "\" or not
If Right(str_Source, 1) <> "\" Then
str_Source = str_Source & "\"
End If
If Right(str_Destination, 1) <> "\" Then
str_Destination = str_Destination & "\"
End If
'PURPOSE:Change directory
ChDir str_Source
Dim str_File As String
str_File = Dir(str_Source & "*.*")
Do Until str_File = ""
FileCopy str_Source & str_File, str_Destination & str_File
str_File = Dir()
Loop
End Sub
If you want to filter out only specific file extensions, play around with the *.
Chemically Formulated As:
Dr. Nitro
-
Jul 29th, 2000, 11:05 AM
#8
Thread Starter
Hyperactive Member
I have no clue how that would work...
Let me try and explain my problem again..there has to be a easier solution...
Ex.
I have 4 files in the same directory:
test.tjf
test.dkj
test.csd
test.kjd
I want to copy all four of thoes files to another directory. I cant simply copy the directory, because there are files other than the ones I want to copy in the directory. Is there an easier way than explained above (that works) to do this?
-
Jul 29th, 2000, 04:37 PM
#9
transcendental analytic
Oh, just one thing i forgot, you need to have both fullpaths with filecopy: Just add Filepart function somewhere in a module
Code:
Dim A as string
A=Dir(Source)
Do
FileCopy A, Destination & "\" & Filepart(A)
A=Dir
Loop While len(a)
Code:
Function Filepart(filepath)
For n = Len(filepath) To 1 Step -1
If Mid(filepath, n, 1) = "\" Then Exit For
Next n
Filepart = Mid(filepath, n + 1)
End Function
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 29th, 2000, 04:48 PM
#10
Fanatic Member
Sac
As I said, play around with the *.*. In this case, you would change the *.* to Test.* because you are copying all files with the name TEST and whatever extensions.
Drop this into a project with only a module and test run it. Make sure in the SUB MAIN below, change it to your source location and destination location.
Code:
Option Explicit
Sub Main()
'Method1
Call p_CopyMethod1("C:\Your Source Directory\Test.*", "C:\Where you want to copy it to")
End Sub
Sub p_CopyMethod1(str_Source As String, str_Destination As String)
Dim v_FileSystemObject As Object
Set v_FileSystemObject = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
'PURPOSE:Copy all files in current directory
v_FileSystemObject.CopyFile str_Source, str_Destination, True
'PURPOSE:Copy all sub directories in current directory
'v_FileSystemObject.CopyFolder str_Source, str_Destination, True
Set v_FileSystemObject = Nothing
End Sub
Once you get this working, check over the codes I posted last night. I putted METHOD1 and METHOD2 mean there are two different ways to do this.
[Edited by Nitro on 07-29-2000 at 06:02 PM]
Chemically Formulated As:
Dr. Nitro
-
Jul 29th, 2000, 06:54 PM
#11
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|