[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!!!:confused:
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:
Dim result As String = ""
Dim ost As String = "jgfdigjfdj$122836785"
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:
If IO.File.Exists(String.Format("c:\{0}.txt)", result)) Then
result &= "(2)"
End If
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...
Re: [2008]. File comparing, renaming and moving!