Jump to content

Move / Copy Csv Files By Date

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...