Hi,
Do you come across any scenario to do regular backup of certain files which are updating regularly and need to put it in a folder with the current date. Herez the simple vb script for that. Copy and paste the below code to any editor and save it as vbs file and run it.
'Declare variables
Dim sCurPath,Fname,strDirectory,objFolder
' Finds the current directory
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
'Replace the / with _ in the date for the valid directory name and
strDirectory = sCurPath & "\" & replace(date,"/","_")
'Create a file system object
Set fso = CreateObject("Scripting.FileSystemObject")
' check whether the directory exists, if not create the directory
if not fso.FolderExists(strDirectory) then
' Crete the directory on the current date
Set objFolder = fso.CreateFolder(strDirectory)
end if
' This copies the files and overwrites them if they exist. You can edit to copy any file type.
fso.CopyFile sCurPath & "\*.txt", strDirectory & "\", OverwriteExisting
wscript.echo "Done"
This article can be found at the blog section of my personal site www.dileepk.info
No comments:
Post a Comment