i have a slight problem when i am grabbing a file via a script and want to rename it. i want to rename it with a variable that is determind from another script but i want to rename it by adding the aariable to the begining of the origianl file name
DOS and use a copy command such as c:\dtt*.csv c:\dest%random%*.csv the only problem with this is that the varibble that you pass infront of the wild card replaces the first few characters (same amount of the variable) witht he variable not adding to it.
anyidea of how i can do this for its slightly driving me insane!
Can’t be done with a one line copy IMHO because you cannot provide input wildcards whilst specifying an output file name, you need a script or a VB script.
Unfortunately there my recollection of DOS commands ends
F1 = “C:\Your PATH for Directory”
ff = “*.csv”
Call FileSearch(F2, ff)
If Len(Found2) > 6 then ’ Length depends on your file size
FileCopy Fod1 & Fod2, “C:\Final Path\Name you wish” & “.csv”
Kill Fod1 & Fod2 ’ Only if you need to delete first file
End if
Function FilesSearch(thepath As String, Ext As String)
Dim unkndir() As String
Dim tempdir As String
Dim ff As String
Dim DirCount As Integer
Dim X As Integer
DirCount = 0
ReDim unkndir(0) As String
unkndir(DirCount) = ""
If Right(thepath, 1) <> "\" Then
thepath = thepath & "\"
End If
DoEvents
tempdir = Dir(thepath, vbDirectory)
Do While tempdir <> ""
If tempdir <> "." And tempdir <> ".." Then
If (GetAttr(thepath & tempdir) And vbDirectory) = vbDirectory Then
unkndir(DirCount) = thepath & tempdir & "\"
DirCount = DirCount + 1
ReDim Preserve unkndir(DirCount) As String
End If
End If
tempdir = Dir
Loop
ff = Dir(thepath & Ext)
Do Until ff = ""
Fod1 = thepath ' & ff
Fod2 = ff
ff = Dir
Loop
'searches through all sub direictories
For X = 0 To (UBound(unkndir) - 1)
FilesSearch unkndir(X), Ext
Next X
End Function