Results 1 to 11 of 11

Thread: Multiple File Copy.....

  1. #1

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    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?
    That arranged can be

  2. #2
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    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!]

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  4. #4

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    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.
    That arranged can be

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  6. #6

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    that didn't work :-((((((((((((
    That arranged can be

  7. #7
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    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

  8. #8

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    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?
    That arranged can be

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  10. #10
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633

    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

  11. #11

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    allright, thanks Nitro
    That arranged can be

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width