Hi All,
many people helped me in my previous post, so thanks to them all - and
i now have a script that works for me...and save me a lot of time.(see
bleow)
however - i do have a new issue now - the script works fine until it
see a column with a slash in it (/) - and therefore wont rename the
file - is there an easy way to say that if it sees a / then name the
file to something?
help is much appreciated once again.
Jason
======================================================================
Const csDir = "Path"
Const csExt = "csv"
Set oFS = CreateObject( "Scripting.FileSystemObject" )
For Each oFile In oFS.GetFolder( csDir ).Files
If 0 = StrComp( csExt, oFS.GetExtensionName( oFile.Name ),
vbTextCompare ) Then
renCSVFile oFile, oFS
End If
Next
Sub renCSVFile( oFile, oFS )
On Error Resume Next
Const ForReading = 1
Dim sNewName : sNewName =
Split( oFile.OpenAsTextStream( ForReading ).ReadLine, "," )( 3 )
oFile.Name = sNewName & "-" & RndFileName & ".csv"
End Sub
Function RndFileName()
For x=1 To 8
Randomize
vChar = Int(36*Rnd)
If vChar < 10 Then 'append number
RndFileName = RndFileName & vChar
Else 'else append a letter
RndFileName = RndFileName & Chr(97+(vChar-10))
End If
Next
End Function
=========================================================================