Results 1 to 3 of 3

Thread: [2008]. File comparing, renaming and moving!

  1. #1

    Thread Starter
    Lively Member esafwan's Avatar
    Join Date
    Apr 2008
    Location
    Bangalore-India
    Posts
    95

    Question [2008]. File comparing, renaming and moving!

    can some one pls assist me on this...
    ____________________________________

    1. I want to rename a bunch of files...
    the files are named like asasa$182829.rtf
    -----I want to rename the file by removing the parts b4 $ sign!
    -----I want to chk if there is 2 files with same name while renaming..that is there is no same file say $19299292...if it is there it should add a (2) at the end!

    Then everything has to be moved to a directory, except the repeated ones!

    Pls help!!!
    Men have become the tools of their tools. - Henry David Thoreau

  2. #2
    Hyperactive Member gnaver's Avatar
    Join Date
    Jul 2005
    Location
    Denmark/Sweden
    Posts
    289

    Re: [2008]. File comparing, renaming and moving!

    to remove som of the string you could use indexOf($), this will tell you where the first $ is in the string... then use, substring to get the new name..

    vb Code:
    1. Dim result As String = ""
    2.         Dim ost As String = "jgfdigjfdj$122836785"
    3.         result = ost.Substring(ost.IndexOf("$"))


    first we check if the new filename exist, if not we add the (2), and then moves the file..

    vb Code:
    1. If IO.File.Exists(String.Format("c:\{0}.txt)", result)) Then
    2.             result &= "(2)"
    3.         End If
    4.  
    5.         IO.File.Move(String.Format("c:\{0}.txt)", ost), String.Format("c:\{0}.txt)", result))

    i havent checked to see if thjis code works, but you should be able to complete the code yourself...

  3. #3

    Thread Starter
    Lively Member esafwan's Avatar
    Join Date
    Apr 2008
    Location
    Bangalore-India
    Posts
    95

    Smile Re: [2008]. File comparing, renaming and moving!

    that was helpful
    Men have become the tools of their tools. - Henry David Thoreau

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