<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Execute command with Variable and wildcard in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19686#M772960</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My script stores qvd files for each day in the format - data_MMDD.qvd.&lt;/P&gt;&lt;P&gt;I have a scenario where at the end of a month, i must delete all the qvd files except the one generated on last day of a month. &lt;/P&gt;&lt;P&gt;example, i must delete all the files from data_0401.qvd to data_0429.qvd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the script i wrote a variable to find out the last month number which I can pass in the execute statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set vLastMonth=AddMonths(Today(),-1);&lt;/P&gt;&lt;P&gt;Let vLastMonthNum = date(date#($(vLastMonth),'DD-MM-YYYY'),'MM');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to write an execute statement, something like below, to delete the files using a variable and wildcard but the files are not getting deleted, I do not get any errors. Can somebody please help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;execute cmd.exe /c del data_$(vLastMonthNum)*.txt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
    <dc:creator>poojask123</dc:creator>
    <dc:date>2020-11-25T16:16:04Z</dc:date>
    <item>
      <title>Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19686#M772960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My script stores qvd files for each day in the format - data_MMDD.qvd.&lt;/P&gt;&lt;P&gt;I have a scenario where at the end of a month, i must delete all the qvd files except the one generated on last day of a month. &lt;/P&gt;&lt;P&gt;example, i must delete all the files from data_0401.qvd to data_0429.qvd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the script i wrote a variable to find out the last month number which I can pass in the execute statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set vLastMonth=AddMonths(Today(),-1);&lt;/P&gt;&lt;P&gt;Let vLastMonthNum = date(date#($(vLastMonth),'DD-MM-YYYY'),'MM');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to write an execute statement, something like below, to delete the files using a variable and wildcard but the files are not getting deleted, I do not get any errors. Can somebody please help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;execute cmd.exe /c del data_$(vLastMonthNum)*.txt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19686#M772960</guid>
      <dc:creator>poojask123</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19687#M772962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello&lt;/P&gt;&lt;P&gt;1 - are you sure of the value of your variable ?&lt;/P&gt;&lt;P&gt;2 - try to enclose the name in quotes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 May 2018 11:45:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19687#M772962</guid>
      <dc:creator>olivierrobin</dc:creator>
      <dc:date>2018-05-28T11:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19688#M772964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="php" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15275089342974948" jivemacro_uid="_15275089342974948" modifiedtitle="true"&gt;
&lt;P&gt;trace &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;execute cmd.exe /c del data_$(vLastMonthNum)*.txt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to see in your log whether the command gets parsed correctly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 May 2018 12:03:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19688#M772964</guid>
      <dc:creator>RonaldDoes</dc:creator>
      <dc:date>2018-05-28T12:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19689#M772966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ronald,&lt;/P&gt;&lt;P&gt;i checked the log file and see that the wildcard is not parsed, it remains as *. The variable value is getting replaced.&lt;/P&gt;&lt;P&gt;I tried multiple of option, none of these worked.&lt;/P&gt;&lt;P&gt;1) execute cmd.exe /c del "test_$(vLastMonthNum)_*.txt;"&lt;/P&gt;&lt;P&gt;2) execute cmd.exe /c del test_$(vLastMonthNum)_*.txt;&lt;/P&gt;&lt;P&gt;3) execute cmd.exe /c del "test_$(vLastMonthNum)_*".txt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i replace the * with a date, its working, but in my case i want it to delete multiple files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Logfile:&lt;/P&gt;&lt;P&gt;29-05-2018 11:02:44: 0011&amp;nbsp; SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun'&lt;/P&gt;&lt;P&gt;29-05-2018 11:02:44: 0013&amp;nbsp; set vLastMonth=AddMonths(Today(),-1)&lt;/P&gt;&lt;P&gt;29-05-2018 11:02:44: 0014&amp;nbsp; Let vLastMonthNum = date(date#(AddMonths(Today(),-1),'DD-MM-YYYY'),'MM')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;29-05-2018 11:02:44: 0018&amp;nbsp; execute cmd.exe /c del test_04_*.txt&lt;/P&gt;&lt;P&gt;29-05-2018 11:02:44: 0021&amp;nbsp; trace this is value 04&lt;/P&gt;&lt;P&gt;29-05-2018 11:02:44: 0021&amp;nbsp; this is value 04&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;29-05-2018 11:02:44:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Execution finished.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 05:34:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19689#M772966</guid>
      <dc:creator>poojask123</dc:creator>
      <dc:date>2018-05-29T05:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19690#M772967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Olivier,&lt;/P&gt;&lt;P&gt;my variable gives me the value i am expecting. Tried to enclose the name in quotes, but din work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 05:35:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19690#M772967</guid>
      <dc:creator>poojask123</dc:creator>
      <dc:date>2018-05-29T05:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19691#M772968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pooja,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're right. I got it working using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="php" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15275763402405517" jivemacro_uid="_15275763402405517"&gt;
&lt;P&gt;Let vLastMonthNum = date(date#(AddMonths(Today(),-1),'DD-MM-YYYY'),'MM');&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;FOR Each File in filelist ('folder\test_$(vLastMonthNum)*.txt')&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Trace Removing file $(File);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; execute cmd.exe /c del "$(File)";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;NEXT File&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Let File = Null();&lt;/P&gt;
&lt;P&gt;Let vLastMonthNum = Null();&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please find the attached example. Make sure to edit the folder structure from my relative "folder\" to whatever you're using.&lt;/P&gt;&lt;P&gt;Also, for production purposes you might want to remove/comment out the trace command to prevent your log from cluttering.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With kind regards,&lt;/P&gt;&lt;P&gt;Ronald&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 06:45:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19691#M772968</guid>
      <dc:creator>RonaldDoes</dc:creator>
      <dc:date>2018-05-29T06:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19692#M772969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;as you try to delete multiple files, a confirmation is asked&lt;/P&gt;&lt;P&gt;try to use del /q&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 10:06:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19692#M772969</guid>
      <dc:creator>olivierrobin</dc:creator>
      <dc:date>2018-05-29T10:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19693#M772970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Ronald. That worked !! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 10:13:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19693#M772970</guid>
      <dc:creator>poojask123</dc:creator>
      <dc:date>2018-05-29T10:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19694#M772971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I also tried the below code, and that worked too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set vLastMonth=AddMonths(Today(),-1);&lt;/P&gt;&lt;P&gt;set myvar = 'test_$(vLastMonthNum)*.txt';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; execute cmd.exe /c del "$(myvar)";&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 12:27:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19694#M772971</guid>
      <dc:creator>poojask123</dc:creator>
      <dc:date>2018-05-29T12:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Execute command with Variable and wildcard</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19695#M772972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I reckon that would be preferable, since you're executing just one command instead of a seperate command for each file.&lt;/P&gt;&lt;P&gt;Upside to the first solution is the added insight into the deleted files since they are all logged by filename.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 12:31:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-command-with-Variable-and-wildcard/m-p/19695#M772972</guid>
      <dc:creator>RonaldDoes</dc:creator>
      <dc:date>2018-05-29T12:31:58Z</dc:date>
    </item>
  </channel>
</rss>

