Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Nov 2003
    Location
    London, Gtr London, England
    Posts
    222
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Renaming external files from within Access (2000 (9.0.4402 SR-1))

    Each week I receive a csv file into a designated folder. My Access DB imports and processes this file. The imported file has a processing period within it and I would like to, somehow from within Access, rename/copy the original csv file with the period attached, in order to have a historical record of the weekly csv files within that folder.

    One method I have tried is exporting the imported file, but this takes quite a long time. Any ideas people?

    Cheers,

    Niven <img src=/S/thinks.gif border=0 alt=thinks width=15 height=15>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Renaming external files from within Access (2000 (9.0.4402 SR-1))

    You can rename an existing file from within Access.

    Dim strCSVFile As String
    Dim strPeriod As String

    ' This is the original file name, known to you.
    strCSVFile = "CesignatedFolderReceived.csv"
    ' This is the period. In reality, you would obtain it from the imported table.
    strPeriod = "200405"
    ' Rename the file by appending strPeriod after the file name, before the extension .csv.
    Name strCSVFile As Left(strCSVFile, Len(strCSVFile) - 4)) & strPeriod & ".csv"

  3. #3
    3 Star Lounger
    Join Date
    Nov 2003
    Location
    London, Gtr London, England
    Posts
    222
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Renaming external files from within Access (2000 (9.0.4402 SR-1))

    Good Man!

    Are you able to copy from within Access as well, i.e. leave the original filename and copy the file to another name?

    Cheers,

    Niven <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Renaming external files from within Access (2000 (9.0.4402 SR-1))

    Certainly, use FileCopy, for example

    FileCopy "C:ReceivedFile1.csv", "C:ReceivedFile2.csv"

    or

    FileCopy "C:ReceivedFile1.csv", "C:OtherFolderFile1.csv"

    The first one copies a file within a folder, changing the name; the second one copies a file to another folder, with the same file name.

  5. #5
    3 Star Lounger
    Join Date
    Nov 2003
    Location
    London, Gtr London, England
    Posts
    222
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Renaming external files from within Access (2000 (9.0.4402 SR-1))

    Doh!

    I have a sieve for a brain. Of course you can.

    Cheers again,

    Niven

Posting Permissions

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