Results 1 to 5 of 5

Thread: rename files

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 1999
    Location
    Skudeneshavn, Norway
    Posts
    38
    Hi

    I have a ListBox with possible new filenames, say 10 items
    and if I at the same time have a FileList with 10 files,
    can I rename all the 10 files with the names I have in the List box in one single action.

    The filenames has to be called 01-10.filename, so the app knows what it is looking for.

    I have tried with For loops but I havent gotten any near it.

    Hope you can help

    Thanks


    Best regrads,

    Chris Davidsen
    Christian Davidsen

    If you go to sleep with an itchy
    ass, you wake up with smelly fingers.

  2. #2
    Addicted Member rbnwares's Avatar
    Join Date
    Sep 2000
    Location
    Philippines
    Posts
    142

    Talking

    Yes. it is possible.
    you can use always use For loops when dealing with collections.

    For example :

    For i = 0 To ListBox.ListCount
    rename FileList.list(i).FileName ListBox.List(i)
    Next i

    I hope that solve your problem.
    Stupidity is better than cure.

    VB6 SP5 Enterprise Ed.
    C, Pascal, VC++ 6.0


    Running Win98 SE and Win2000 Prof. Ed.


    Email me at : [email protected]

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 1999
    Location
    Skudeneshavn, Norway
    Posts
    38

    wrong number or argument

    Hi rbnwares

    I tried your code

    amd my code looks like this
    --------------------------------------
    Dim Oldname
    Dim Newname

    For i = 0 To List1.ListCount
    Label1 = i

    Oldname = Dir1.Path & "\" & File1.List(i).filename
    Newname = Dir1.Path & "\" & List1.List(i)

    Name Oldname As Newname

    Next i
    ---------------------------------------


    but it does not like File1.List(i), wrong argument

    do you have any other clues

    Thanks


    Chris Davidsen
    Christian Davidsen

    If you go to sleep with an itchy
    ass, you wake up with smelly fingers.

  4. #4
    Hyperactive Member WP's Avatar
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    278

    Wink Listindex

    try list1.listindex=i instead of list1.index(i)

    WP

    Visual Basic 6.0 EE SP5 / .Net
    Windows XP

  5. #5
    Guest
    i think your error might be in the fact that i becomes too big. use the list count but subtract one as in below.


    For i = 0 To ListBox.ListCount - 1
    rename FileList.list(i).FileName ListBox.List(i)
    Next i

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