Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming/Deleting folders/Files

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
friend of mine wanted to knmow how to do this(until he can get the internet hooked back up)<br>
'<br>
i want to rename alot of folders containing version numbers but the folders are sepreated by .'s like &quot;free.and.easy.v3.40&quot;<br>
i want to remove all the .'s execpt the ones int he version #<br>
im going from linux to windows<br>
'<br>
<p>Karl<br><a href=mailto:kb244@bellsouth.net>kb244@bellsouth.net</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(hehe, yea it was 4.5 too, least i didnt start with COBOL)
 
Assuming that every version number has one dot in it, and that you want to keep the dot immediately before the version number (requires VB6):<br>
<br>
Sub RenameIt(filename As String)<br>
Dim i As Integer<br>
Dim newname As String<br>
i = InStrRev(filename, &quot;.&quot;, Len(filename))<br>
i = InStrRev(filename, &quot;.&quot;, i - 1)<br>
newname = Replace(Left(filename, i - 1), &quot;.&quot;, &quot;&quot;) & Mid(filename, i)<br>
Name filename as newname<br>
end sub<br>
<p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
hmm he has VB5, that i know of, and the version numbers i dont think is always gona have just one dot, or maybe it will since i dont often see many v4.3.8<br>
<p>Karl<br><a href=mailto:kb244@bellsouth.net>kb244@bellsouth.net</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(hehe, yea it was 4.5 too, least i didnt start with COBOL)
 
Um, he's really beginning at this, yes its nice to know you can just change the name of a string, but he needs to know how to traverse thru the tree, and the actual renaming command to use <p>Karl<br><a href=mailto:kb244@bellsouth.net>kb244@bellsouth.net</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(hehe, yea it was 4.5 too, least i didnt start with COBOL)
 
sorry my bad, the name command does the renaming, but i happen to comment out the line with the InStrRev, and commented out the Name command to test it on some string, i found using the Replace i can just chang eall the periods to spaces(and no its not just one period), figuring that if i can find the mask of *v#.##..*&quot; then taking that section out, and renaming every period around that section. <p>Karl<br><a href=mailto:kb244@bellsouth.net>kb244@bellsouth.net</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(hehe, yea it was 4.5 too, least i didnt start with COBOL)
 
ok finally got it<br>
<br>
Sub RenameIt(filename As String)<br>
Dim i, startF, endF As Integer<br>
i = 1<br>
Dim lexit As Boolean<br>
Dim newFront, newBack, newVer, NewF2, NewB2 As String<br>
While i &lt;= Len(filename) And lexit &lt;&gt; True<br>
If Mid(filename, i, 2) = &quot;.v&quot; Then<br>
startF = i<br>
i = i + 2<br>
If i &lt;= Len(filename) Then<br>
While (Mid(filename, i, 1) = &quot;.&quot; Or IsNumeric(Mid(filename, i, 1))) And (i &lt;= Len(filename))<br>
i = i + 1<br>
Wend<br>
If (Mid(filename, i - 1, 1) = &quot;.&quot;) Then<br>
endF = i - 1<br>
Else<br>
endF = i<br>
End If<br>
lexit = True<br>
End If<br>
End If<br>
i = i + 1<br>
Wend<br>
newVer = Mid(filename, startF + 1, (endF - startF))<br>
newFront = Replace(Mid(filename, 1, startF), &quot;.&quot;, &quot; &quot;)<br>
newBack = Replace(Mid(filename, endF, Len(filename)), &quot;.&quot;, &quot; &quot;)<br>
NewF2 = LCase(newFront)<br>
NewB2 = LCase(newBack)<br>
For j = 0 To List1.ListCount - 1<br>
NewB2 = Replace(NewB2, LCase(List1.List(j)), &quot;&quot;)<br>
NewF2 = Replace(NewF2, LCase(List1.List(j)), &quot;&quot;)<br>
Next j<br>
'Name filename As newname<br>
Text1.Text = NewF2 & newVer & NewB2<br>
End Sub <p>Karl<br><a href=mailto:kb244@bellsouth.net>kb244@bellsouth.net</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(hehe, yea it was 4.5 too, least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top