2 Replies Latest reply: Dec 28, 2017 11:37 AM by Peter Turner RSS

    Execute Batch File to Move files between shared folders

    Abhay Sudhakaran

      I am trying to move files between 2 shared folders, for which i would like to use a dynamic batch file that takes parameters.

      Is there a way to get this working in QLik Sense. I remember it used work like (shown below). But for some reason this doesnt work anymore:

       

      SOLUTION 1 (NOT WORKING: AFTER THE RECENT UPGRADE to Qlik June Release)

      // Define Destination Folder Locations

      // Let vDataLake = 'lib://Dev_DataLake';

      Let F1 = '\\Testing\F1\';

      Let F2 = '\\Testing\F2\';

       

      // Function for moving old files to archive

      // ----------------------------------------------------

      SUB Qv.MoveFiles (FileArchive,DestArchive)

       

          Let copycmd = 'cmd.exe /c Move "$(FileArchive)"' & ' "$(DestArchive)"' ;

          EXECUTE $(copycmd);

       

      ENDSUB

       

       

      // Archive Previous Monthly Files

      Let vFileName = '$(F1)' & '*.txt';

      Call Qv.MoveFiles('$(vFileName)','$(F2)');

       

       

      SOLUTION 2 (NOT WORKING : Hard Coded Folder Paths in Batch Script)


      1. Create a batch file called "Move.bat" in the destination folder (with hardcoded folder locations)

      Move /y "\\Testing\F1\*.*" "\\Testing\F2\"

      2. In Load script add this line

      Execute '\\Testing\F1\Move.bat'; or create a folder library path and use that instead

       

      SOLUTION 3 (NOT WORKING : Dynamic Batch Script using parameters)

      1. Create a dynamic batch file

      echo off

      set src=%1

      set dest=%2

      cmd.exe  /c Move  %src% %dest%

       

      2. Add this line in load script

      Execute '\\Testing\F1\Move.bat  "F1" "F2"';



      IMPORTANT NOTE:

      The Settings.ini file looks like this:

      ----------------------------------------------

      [Settings 7]

      OverrideScriptSecurity=1

        • Re: Execute Batch File to Move files between shared folders
          Abhay Sudhakaran

          The ONLY way I am able to get this working is by:

          1. Putting the batch file in a local folder on the Qlik Sense Server.

          2. Then create a library path for that folder location in the Qlik Sense App

          3. Hardcode the folder location in the batch file. Like this

          Move /y "\\Testing\F1\*.*" "\\Testing\F2\"

          4. Execute the batch file using that library path. Like this:

          Execute [lib://ASTesting/Move2.bat] ;

            • Re: Execute Batch File to Move files between shared folders
              Peter Turner

              Hi Abhay,

               

              I think i'm having similar behaviour with a script that was previosuly working fine, but now does not with our QS Nov installation.

              In my example i'm automating the ForFiles command, when i run my command from inside QS this does nothing, but when i use the exact same command directly into a cmd prompt, it works fine.

               

              The required settings.ini and QS Engine settings are in place to enable 'legacy mode'. Strange that only certain commands are affected, others still run with the Execute command as expected.