+ Reply to Thread
Results 1 to 2 of 2

Change names of Files in a folder

  1. #1
    TISR
    Guest

    Change names of Files in a folder

    I copy all these files into a new folder
    File names are of standard = "XXXX MmmYy"
    Thus I need to change their names to ""XXXX Mmm-1Yy"
    So the code that I have is
    Const Dest = "C:\Mis documentos\12 December 2005"
    Dim FSO As Object
    Dim f, f1, fc
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set f = FSO.GetFolder(Dest)
    Set fc = f.Files
    For Each f1 In fc
    f1.Name = Mid(f1.Name, 1, (Len(f1.Name) - 9)) &
    Dateserial(year,month-1)
    Next
    It stops in the For next loop
    Can someone help?

  2. #2
    Bob Phillips
    Guest

    Re: Change names of Files in a folder

    Not sure what names you are trying to give, but try this

    Const Dest = "C:\Mis documentos\12 December 2005"
    Dim FSO As Object
    Dim f, f1, fc
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set f = FSO.GetFolder(Dest)
    For Each f1 In f.Files
    Name f1.Path As Mid(f1.Name, 1, (Len(f1.Name) - 9)) & _
    Format(DateSerial(Year(Date), Month(Date) - 1, 1), "yyyy-mm")
    Next f1

    Take backups first!

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "TISR" <[email protected]> wrote in message
    news:[email protected]...
    > I copy all these files into a new folder
    > File names are of standard = "XXXX MmmYy"
    > Thus I need to change their names to ""XXXX Mmm-1Yy"
    > So the code that I have is
    > Const Dest = "C:\Mis documentos\12 December 2005"
    > Dim FSO As Object
    > Dim f, f1, fc
    > Set FSO = CreateObject("Scripting.FileSystemObject")
    > Set f = FSO.GetFolder(Dest)
    > Set fc = f.Files
    > For Each f1 In fc
    > f1.Name = Mid(f1.Name, 1, (Len(f1.Name) - 9)) &
    > Dateserial(year,month-1)
    > Next
    > It stops in the For next loop
    > Can someone help?




+ Reply to 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