by MYLE
3. March 2011 20:39
Had a client ask me
I want a Dropbox where he wanted to drop a jpg on on the vbs copy it to a differance location BUT give it the name of the script.jpg
well that got me thinking
can i get the name of the running script yes FileName = WScript.ScriptName
can i get what been drop on it Set objArgs = WScript.Arguments
can i return the file status fso.FileExists(filespec)
so put all in on
'***************************************************************
' Copyright 2011 MYLE (Making Your Life Easy)
'
' Written By: StePhan Mckillen
' Please leave the Copyright notes
'***************************************************************
Const CopyTo = "E:\TNL\tofolder\"
'*************************************************************
' Please do not change anything pass this point
'*************************************************************
dim ws, filesys, objargs
Set ws = WScript.CreateObject("WScript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
FileName = WScript.ScriptName
For Each strArg in objArgs
set ReplaceFile = filesys.getfile(strArg)
ext=Split(replacefile.name,".")
filename = replace(Ucase(filename),"VBS",ext(1))
if ReportFileStatus(Copyto & filename) then
if Msgbox("Replace" & vbnewline & replacefile.name & " >>> " & filename,vbyesno)=vbyes then
filesys.Copyfile replacefile , CopyTo & filename ,true
Msgbox("Done :" & replacefile.name & "=>" & CopyTo & filename )
else 'dont Copy it
End if
else
filesys.Copyfile replacefile , CopyTo & filename ,true
Msgbox("Done :" & replacefile.name & "=>" & CopyTo & filename )
End if
Next
Function ReportFileStatus(filespec)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = true
Else
msg = false
End If
ReportFileStatus = msg
End Function
so if i
dd7df575-c9d6-4dd7-ac41-1baab33a7d1a|0|.0