Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dasu
Posting Yak Master
104 Posts |
Posted - 2004-09-14 : 07:48:24
|
Please tell me the solution for delete all the files which name has following charactersjobid_filenamelikejobid=122then 122_filenamei want to delete all the files preceded by this jobidthis file is there in another directoryplase suggest me the vbscript code for this<edit> moved to developer forum </edit> |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-14 : 07:57:43
|
maybe this:delete from MyTablewhere jobid like '%122_%'but you could do in command line del *122_*.* Go with the flow & have fun! Else fight the flow |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-09-14 : 08:10:33
|
or vbscript like this.--*****************************[CODE]Public objFileSystemSet objFileSystem = WScript.CreateObject("Scripting.FileSystemObject")MainSet objFileSystem = NothingSub Main() ' Get the Deletion Pattern If WScript.Arguments.Count < 1 Then Pattern = InputBox("What is the search string of the files that you want to delete") If Pattern = "" Then Exit Sub End If Else Pattern = WScript.Arguments(0) End If On Error Resume Next objFileSystem.DeleteFile Pattern, True On Error GoTo 0 ' get EQ domain files movedEnd Sub[/CODE]save this into a .vbs filethen from the command prompt type filename.vbs 122_*.*Hopefully this works :)Duane. |
|
|
dasu
Posting Yak Master
104 Posts |
Posted - 2004-09-16 : 06:25:02
|
i got the solution i think it s useful for others nowiam posting the answer. this is the way strOutSpoolPath=DTSGlobalVariables("gstrHomeDir").Value&"\feeds\outboundspool\"&DTSGlobalVariables("gstrFilePath").Valueif(objFso.FolderExists(strOutSpoolPath)) thenset objFolder =objFso.GetFolder( strOutSpoolPath) set colFiles =objFolder.Files if colFiles.Count > 0 then For Each objFile in colFiles Set objFso = CreateObject("Scripting.Filesystemobject") strFile=objFile.name if (CINT( left(strFile,DTSGlobalVariables("gintCount").Value))=(DTSGlobalVariables("gintJobId").Value)) then If (objFso.FileExists(strOutSpoolPath&strFile) )then DTSGlobalVariables("gstrErrorOutputFile").Value="Error_" & strFile strErrAbslPath=DTSGlobalVariables("gstrHomeDir").Value&"\feeds\errors\"&DTSGlobalVariables("gstrFilePath").Value&DTSGlobalVariables("gstrErrorOutputFile").Value strFile = strOutSpoolPath&strFile objFso.MoveFile strFile ,strErrAbslPath end if end if next end if end if |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-09-16 : 06:42:34
|
Hi Dasu,You would probably had a quicker solution to your problem - If you had mentioned that the vbscript was to be in an activex task and put in the dts forum.Duane. |
|
|
dasu
Posting Yak Master
104 Posts |
Posted - 2004-09-16 : 10:01:18
|
hello, duane can u tell me the dts forum id clearly please regards dasu.g |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-09-16 : 10:05:24
|
http://www.sqlteam.com/forums/forum.asp?FORUM_ID=13Duane. |
|
|
|
|
|