Hi Friends,
Please let me know how we can do the copy operation of a file using vbscript code?
Regards,
pradeep
Hi Friends,
Please let me know how we can do the copy operation of a file using vbscript code?
Regards,
pradeep
Hi,
Try this -
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("c:\sourcefolder\anyfile.html") Then
filesys.CopyFile "c:\sourcefolder\anyfile.html", "c:\destfolder\"
End If
The FileSys.CopyFile method should work. Just remember to pass the Source and Destination paths correctly.
Cheers...
Hi Pradeep,
Try fhis,
This is for Copying a file (located in desktop) into a folder (located into desktop)
Set Shell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
SourceDesktopPath = Shell.SpecialFolders("Desktop") + "\rajaputra.txt" 'we can use either & or + to concotinate the strings
DestinationDesktopPath = Shell.SpecialFolders("Desktop") + "\Destination\"
FSO.CopyFile SourceDesktopPath, DestinationDesktopPath
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Arunsingh Rajaputra
Software Test Engineer
[QUOTE=bizzzzzare;23981]Hi,
Thank you Bizzzz
Here is a script which alos rename the file with concotinate date and time:
Sub BackupExistFiles(FileName,ExcelPath)
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(ExcelPath & FileName) Then
newName=Replace(Date,"/","_")&"_"&Replace(Time,":","-")
filesys.CopyFile ExcelPath & FileName, ExcelPath & "tmp\"&NewName&"_"&FileName
End If
End Sub
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The above code is working perfectly working for me.
But I have a scenario in which I need to copy some files from latest modified folder to destination folder. (may not know the folder name exactly) unless i go see it.
Could you kindly help to fulfill this scenario.
Thanks in advance.
Kailash