Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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
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.
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
Ok, so I could execute a BAT-file?
//cristian
Yeah, that's what we do to back-up the previous .csv files before loading a new one.