ekkehard
Mon Jan 02 12:40:31 CST 2006
deckhopper wrote:
> Here's a script that may work for you. Test it out using a sacrificial
> folder first. This was the best I could do given the limited amount of
> information you have here. If you need more tweaking of this script,
> reply back or tinker around with the script.
[...]
> For Each objFile in colFiles
>
> longName = objFile.Name
> shortName = objFSO.GetFileName(longName)
> extNameOnly = objFSO.GetExtensionName(shortName)
>
> If extNameOnly = "xfr" Then
> ReDim Preserve arrFileNumber(x)
> arrFileNumber(x) = Mid(shortName,4,2)
> End If
>
> If extNameOnly = "txt" Then
> newName = Left(shortName,8) & arrFileNumber(y) & ".txt"
> MsgBox newName & vbCr & vbCr & longName
> MoveAFile longName, newName
> y = y + 1
> End If
>
> x = x + 1
> Next
[...]
> tim_wallace@games-workshop.com.au wrote:
>
>>Hello everyone,
>>
>>I am trying to find a way to rename files that get loaded onto a server
[...]
>>For example some of the files we get are as follows -
>>
>>r29-dcom.txt, arr56r29.xfr
>>r15-dcom.txt, arr22r15.xfr
>>
>>Now I need to rename the r29-dcom.txt and r15-dcom.txt files to have
>>the number that the XFR files has. So after renaming them I would end
>>up with the following.
>>
>>r29-dcom56.txt, arr56r29.xfr
>>r15-dcom22.txt, arr22r15.xfr
[...]
Hi deckhopper,
I reply to your message because Tim and I (ehvbs) are discussing
Tim's problem at
http://www.visualbasicscript.com/m_29213/tm.htm
and I think it wouldn't be fair if you were not aware of this fact.
Because of this discussion I tested your script and learned something
new (for me) about using WMI to access the filesystem. Thank you for
that.
There is just one problem: I can't see how your code keeps track
of the paired files to make sure that eg r29-dcom.txt is renamed
according to arr56r29.xfr (and not arr22r15.xfr). I tried to
comprehend your usage of x and y, but I need your help/explanation
to understand it.