Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
How can i delete all Text Files from a particular folder in my machine by using Qlikview.
Example:
IN my machine D:\Data\TextFiles folder having for 4 text files. Now i want to delete the files by using the Qlikview functionality.
How can i do it.
Thanks in advance.
Regards
Venkat
Hi Venkat,
try this:
execute cmd.exe /c del *.txt;
- Ralf
Hi,
For that you need to search for VBScript code to achieve this, as this is not a part of Qlikview.
But you can use that code in Qlikview as Qlikview supports VBScript.
Regards,
Kaushik Solanki
Hi, If you want to delete files using macro, this is the code : (it will delete only text files in the folder C:\Folder)
sub DeleteFiles
Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.DeleteFile "c:\Folder\*.txt"
end sub
You can also see it working in the attachment (you need to allow system access to macros)
Hope this helps,
Erich
If you want to do it from script, this is the code:
EXECUTE del C:\Folder\*.txt /q
On the script window, settings tab (bottom of the screen), you need to mark 'Can execute external program'
Regards,
Erich
Hi Erich,
Thanks for your reply.
Pls can you explain little more clear on doing through EditScript.
I didn't get you point.
Regards
Venkat
Hi,
This is a line you should include in your script:
EXECUTE del C:\Folder\*.txt /q
The execute command will send it to windows. It's the same as opening DOS prompt and writing the command there.
Del will exclude .txt files in the folder C:\Folder\
the /q parameter will make this command run quietly (without opening the prompt window or showing messages when it finishes)
Hope it helps,
Erich
Hi Erich,
Sorry for very late reply.
I tried your Script code but generating an error "SCRIPT LINE ERROR".
Pls see the attached document. And update me where i am done wrong.
Regards
Venkat.
Hi Venkat,
try this:
execute cmd.exe /c del *.txt;
- Ralf
Hi Ralf Becher,
With Edit script it working fine now.
And now i am trying with macro code but it is not deleting the files from folder.
Always it is geneating Else part msgbox i.e; NO FILES TO DELETE. The folder contains Text files also but it is not entering into "if loop".
Pls check the below macro code.
Sub DeleteFiles
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("D:\TestAllFlatFiles\*.txt") then
filesys.DeleteFile "D:\TestAllFlatFiles\*.txt"
Msgbox("Files Deleted")
Else
Msgbox("No Files to delete")
End If
End Sub
Thanks in Advance.
Regards
Venkat
Hi Venkat,
this will not work. You have to loop over files:
HTH,
- Ralf