Closed Thread
Results 1 to 3 of 3

Renaming Non-Excel Files

  1. #1
    QTGlennM
    Guest

    Renaming Non-Excel Files

    I am trying to figure out if I can rename non-excel files with excel.
    I have a sheet with my file names in column A

    G:\New Folder\Blank DA 1594.FPK
    G:\New Folder\DA 1594 Example.pdf

    and in column B I have the new names that I want to change them to.

    G:\New Folder\Blank DA 1594 27 July 06.FPK
    G:\New Folder\DA 1594 27 July 06.pdf

    If anyone can help I would greatly appreciate it!!!!
    Thanks in advance.

    Glenn


  2. #2
    Die_Another_Day
    Guest

    Re: Renaming Non-Excel Files

    Sub MoveFile()
    Dim fso
    Dim file As String, sfol As String, dfol As String, destFile
    file = "Test.txt" ' change to match the file name
    destFile = "TestMe.txt"
    sfol = "C:\" ' change to match the source folder path
    dfol = "C:\" ' change to match the destination folder path
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FileExists(sfol & file) Then
    MsgBox sfol & file & " does not exist!", vbExclamation, "Source
    File Missing"
    ElseIf Not fso.FileExists(dfol & file) Then
    fso.MoveFile (sfol & file), dfol & destFile
    Else
    MsgBox dfol & file & " already exists!", vbExclamation,
    "Destination File Exists"
    End If
    End Sub

    HTH

    Die_Another_Day
    QTGlennM wrote:
    > I am trying to figure out if I can rename non-excel files with excel.
    > I have a sheet with my file names in column A
    >
    > G:\New Folder\Blank DA 1594.FPK
    > G:\New Folder\DA 1594 Example.pdf
    >
    > and in column B I have the new names that I want to change them to.
    >
    > G:\New Folder\Blank DA 1594 27 July 06.FPK
    > G:\New Folder\DA 1594 27 July 06.pdf
    >
    > If anyone can help I would greatly appreciate it!!!!
    > Thanks in advance.
    >
    > Glenn



  3. #3
    Ron de Bruin
    Guest

    Re: Renaming Non-Excel Files

    You can also use the VBA Name function

    Name "C:\SourceFolder\Test.xls" As "C:\DestFolder\TestNew.xls"


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "Die_Another_Day" <[email protected]> wrote in message news:[email protected]...
    > Sub MoveFile()
    > Dim fso
    > Dim file As String, sfol As String, dfol As String, destFile
    > file = "Test.txt" ' change to match the file name
    > destFile = "TestMe.txt"
    > sfol = "C:\" ' change to match the source folder path
    > dfol = "C:\" ' change to match the destination folder path
    > Set fso = CreateObject("Scripting.FileSystemObject")
    > If Not fso.FileExists(sfol & file) Then
    > MsgBox sfol & file & " does not exist!", vbExclamation, "Source
    > File Missing"
    > ElseIf Not fso.FileExists(dfol & file) Then
    > fso.MoveFile (sfol & file), dfol & destFile
    > Else
    > MsgBox dfol & file & " already exists!", vbExclamation,
    > "Destination File Exists"
    > End If
    > End Sub
    >
    > HTH
    >
    > Die_Another_Day
    > QTGlennM wrote:
    >> I am trying to figure out if I can rename non-excel files with excel.
    >> I have a sheet with my file names in column A
    >>
    >> G:\New Folder\Blank DA 1594.FPK
    >> G:\New Folder\DA 1594 Example.pdf
    >>
    >> and in column B I have the new names that I want to change them to.
    >>
    >> G:\New Folder\Blank DA 1594 27 July 06.FPK
    >> G:\New Folder\DA 1594 27 July 06.pdf
    >>
    >> If anyone can help I would greatly appreciate it!!!!
    >> Thanks in advance.
    >>
    >> Glenn

    >




Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1