Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Copy and delete text files?

Hello,

I would like to load a text file from a folder 'Infiles', then I would like to move the file to the folder 'Oldfiles'. That is I would like to delete the file from 'Infiles' when I have loaded the file and save a copy of it in the 'oldfiles' folder. Is this possible? Could this be done in QV script?

//Cristian

6 Replies
Not applicable
Author

QlikView doesn't have a sentence for deleting files, only can write (STORE). You should delete files manually.

I think exists other possibility, You can probably do it in VBScript, but I not sure.

Regards.

Not applicable
Author

Hi Christian

You can access the local file system with macros. You need to give rights to this and you might run into problems using a server hosted document.

Juerg

Not applicable
Author

Here is a sample macro for copying a file to a new location. You must change the Current Local Security to Allow System Access in the macro window:

Sub CopyFile
strFilePath = "x:\orig_file.txt"
strDestination ="x:\newpath\dest_file.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFileCopy = objFSO.GetFile(strFilePath)
objFileCopy.Copy (strDestination)
End Sub


You can probably find more commands by searching for the FileSystemObject.

Not applicable
Author

You can use the Execute keyword to run a command from within a load script without macros.

First you need to allow external programs... in the load script editor > settings tab (at bottom) > check "Can Excecute External Programs"

Now you can use the Execute keyword to run a command... but need to start "cmd.exe /C" to run as though on command line.

execute cmd.exe /C move InFiles\TestData.txt Outfiles\TestData.txt


Not applicable
Author

Ok, so I could execute a BAT-file?

//cristian

Not applicable
Author

Yeah, that's what we do to back-up the previous .csv files before loading a new one.