Results 1 to 8 of 8

Thread: Append a folder????

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Question

    Is there any way of opening a FOLDER for append.
    Something like:
    Code:
    Open "Pathname/foldername" for Append
    I want to move files from one folder to another without deleting any files in the target folder.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    [copy]
    'copy the contents of a floppy to a folder on a different drive
    'copies files and folders seperately as they use different vehicles
    '

    Public Sub CopyA()
    Dim FSO As Object
    On Error GoTo NOFSO
    Set FSO = CreateObject("Scripting.FileSystemObject")

    On Error Resume Next
    FSO.CopyFile "A:\*", "C:\My Documents\", True
    FSO.CopyFolder "A:\*", "C:\My Documents\", True
    Set FSO = Nothing
    Exit Sub
    NOFSO:
    MsgBox "FSO CreateObject Failed"
    End Sub
    [/code]
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Is there any way to delete the origional files after the files have been copied. Like a MoveFile instead of CopyFile????

  4. #4
    Guest
    I don't think there is a way to move files using VB Code. You'd have to use the FileCopy and Kill statements. And if the files are the same name, I think they will be overwritten automatically.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Thanks for the help guys,
    How would I go about using KILL? If I put it straight after the fileCopy, will that work?
    Thanks again
    JK

  6. #6
    Guest
    Are you saying you want to copy the file and then delete the file you copied since it doesn't move itself?

    Copy the file first:

    Code:
    FileCopy "C:\Myfile.txt", C:\MyProgram\Myfile.txt"
    And then delete the file:

    Code:
    Kill "C:\Myfile.txt"

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Yes that's it. The only problem that I have is that I don't know the name of the file. It's all based on the file extension. I want to copy all files in the folder with a file extension of .htm and leave all other files with different file extensions in the folder. Any ideas?

    Code:
    Private Sub Timer1_Timer()
    Call CopyA
    End Sub
    
    Public Sub CopyA()
    Dim FSO As Object
    On Error GoTo NOFSO
    Set FSO = CreateObject("Scripting.FileSystemObject")
    
    On Error Resume Next
    FSO.CopyFile "C:\Documentation\*.htm", "C:\Test\", True
    FSO.Kill "C:\Documentation\*.htm"
    Set FSO = Nothing
    Exit Sub
    NOFSO:
    MsgBox "FSO CreateObject Failed"
    End Sub
    All the files are copied to the folder ok, but they won't delete from the original folder. Any Suggestions

    [Edited by kanejone on 09-12-2000 at 05:11 AM]

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Another question if possible. The folder that I'm putting the files into is actually going to be generated just before I do the FileCopy. This is how the folder name is going to be generated.

    Code:
    Private Function MakeFolder(NewDir As String)
    Dim dirname As String
    dirname = "C:\Documentation JK\"
    NewDir = dirname & NewDir
    MkDir NewDir
    End Function
    
    Private Sub Archive_Click()
    today = Format(Now, "dd mmmm yyyy")
    MakeFolder (today)
    Call CopyA
    End Sub
    So what I need to do is something like this:
    Code:
    FSO.CopyFile "C:\Documentation\*.htm", "C:\Test\MAKEFOLDER(today)", True
    Is there any way to do this???
    Thanks for the time you've taken, I really to appreciate it

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