Jump to content

Move / Copy Csv Files By Date


roystony01

Recommended Posts

Hi All, I am a beginner in writing VBS. I am trying to write a script that will copy a csv file that contains todays date, and move it to another folder, and also rename the file without the date. This is the script I have, there are no errors when I run the script, but nothing actually happens. i have been scratching my head for a few days now. Please note I have changed the folder paths, as these are sensitive and cant be shared publicly, but I am positive there are noe read write issues, and they are written correctly Any help, muchly appreciated. Roy Sub Copy_Files_Dates() Dim FSO Dim FromPath Dim ToPath Dim Fdate Dim FileInFromFolder DIM FName FromPath = ("C:\folder") ToPath = ("C:\folder") If Right(FromPath, 1) <> ("\") Then FromPath = FromPath & "\" End If If Right(ToPath, 1) <> "\" Then ToPath = ToPath & "\" End If FSO = CreateObject("scripting.filesystemobject") If FSO.FolderExists(ToPath) = False Then MsgBox(ToPath & " doesn't exist") Exit Sub End If For Each FileInFromFolder In FSO.getfolder(FromPath).Files Fdate = Int(FileInFromFolder.DateLastModified) FName = String(FileInFromFolder.Name) If Fdate >= int(now()) AND Left(FName,9) = ("ARBDWeek1") Then FileCopy FromPath & FName, ToPath & ("ARBDWeek1.csv") End If NextEnd Sub

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...