VBScript insert date within route

1

I'm doing a process in VBScript. I need to copy some files from one folder to another. That is already done, but the problem is that the name of the folder from which it is copied varies every week, because it corresponds to the date. That's right: Sem_20170228 .

Then I need that within the string of the name, add that variable. The date is formatted so that YYYYMMD appears like this and the code was messed up

Code:

Option Explicit


Dim g_oSB : Set g_oSB = CreateObject("System.Text.StringBuilder")

Function sprintf(sFmt, aData)
   g_oSB.AppendFormat_4 sFmt, (aData)
   sprintf = g_oSB.ToString()
   g_oSB.Length = 0
End Function


Dim fso
Dim dt : dt = now()


'WScript.Echo sprintf("{0:yyyyMMdd}", Array(dt))
Set fso = CreateObject("Scripting.FileSystemObject")

If 
    filesys.FileExists("C:Bibliotecas\Documentos\Sem_" +dt "\*.pdf")
Then

'filesys.CopyFile "C:Bibliotecas\Documentos\Sem_" +dt "\*.pdf", "C:\Users\alpnheg\Documents\TUTORIALES"
    
asked by Nicole H. 28.02.2017 в 21:37
source

1 answer

2

Thanks for the interest, I already solved it greetings

Dim ruta1, ruta2
ruta1 = "C:\Ruta_inicio\Sem_"& Year(Date) & Right("0" & Month(Date),2) & Right("0" & Day(Date),2) &"\*.pdf"
ruta2 = "C:\Ruta_destino"

Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile (ruta1) , (ruta2)
    
answered by 01.03.2017 в 16:03