Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VB Script to move a file with date in name

$
0
0

I'm so stuck but I know Im close.  So its friday and I'm brain dead and I'm asking for some help please.

I have FILES starting with dates

140729HDF0.835

140730HES0.835

140731UHG0.835

and I need to move the files that are dated in the file's 2 days back.

Dim ObjFso 
Dim SourceLocation 
Dim DestinationLocation 
Dim FileName
Set ObjFso = CreateObject("Scripting.FileSystemObject")  
dteYesterday = DateAdd("d", -1, Date) 
SourceLocation = "c:\835old" 
DestinationLocation = "c:\835new" 
FileName = (Year(dteYesterday), 2) & Right("0" & Month(dteYesterday), 2) & Right("0" & Day(dteYesterday), 2) & ".835"
ObjFso.MoveFile SourceLocation & "\" & FileName, DestinationLocation & "\"

It's something in my FileName= because if I simply change it to

FileName = "*.835"
its works.  Can anyone help please??


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>