Author Topic: Fun with files  (Read 4706 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Fun with files
« on: December 04, 2015, 10:44:35 AM »
Here's a fun one for folks who like to kick it old-school.

**Caution: For experienced users or those with more technical background**

Scan any directory/subdirectory and capture all the file paths etc. Nice if you want to generate payload xml to access certain files directly, rather than through one of the standard media player plugins, for example. Of course, there are other uses as well.

James originally experimented with this using Launch.CMD, but using Launch.Capture turns out to be much neater and more reliable across systems (I think). So, once again: hat-tip to Master James. ;)

http://voxcommando.com/mediawiki/index.php?title=Actions#Launch

Here is an example where we scan our NAS movies directory and then generate a payload xml of all the movie files. Included are some sample commands that then launch and play any of the titles using your default movie player if you have one.

You could do the same thing with folders of Word documents, or whatever.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.9-->
<commandGroup open="False" name="example - scan movie folders to create payload xml" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="344" name="Scan movie folder" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Launch.Capture</cmdType>
      <params>
        <param>C:\Windows\System32\cmd.exe</param>
        <param>/C dir \\NAS\video\Movies\*.??? /s /b /A:-D</param>
        <param>True</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RegExTool.Open</cmdType>
      <params>
        <param>True</param>
      </params>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>(.*\\)(.*?)(  \.mkv  |  \.avi  |  \.mp4)</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PayloadXML.Clear</cmdType>
      <params>
        <param>payloads\myMovies.xml</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PayloadXML.AddPair</cmdType>
      <params>
        <param>payloads\myMovies.xml</param>
        <param>{Match.{i}}</param>
        <param>{Match.{i}.2}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>created xml with {#m} movies</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Scan my movie folder</phrase>
  </command>
  <command id="345" name="play my movie" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Launch.OpenFile</cmdType>
      <params>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Now playing {PF.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>play my movie</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\myMovies.xml</payloadFromXML>
  </command>
  <command id="381" name="play a random movie" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PayloadXML.GetRandomP</cmdType>
      <params>
        <param>payloads\myMovies.xml</param>
        <param>1</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Now playing {Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PayloadXML.GetValue</cmdType>
      <params>
        <param>payloads\myMovies.xml</param>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.OpenFile</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>play a random movie</phrase>
  </command>
</commandGroup>

If you're too young to know how to use command line stuff, now's your chance to see how it works and explore how these fundamental concepts can be enriched in the VC environment.

To experiment with the above xml, you'll have to replace our NAS path with an appropriate equivalent on your system.

I find the SS64 website is a great reference for command syntax. http://ss64.com/nt/ (in this case, follow the "Dir" link)
« Last Edit: January 02, 2016, 08:50:00 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Fun with files
« Reply #1 on: December 04, 2015, 01:13:14 PM »
Wow great idea  8)
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Fun with files
« Reply #2 on: December 04, 2015, 03:07:47 PM »
Agreed. :)

It's so versatile.

The only thing is, if you want to generate a payload XML file for a really large number of items, then the method I use above (PayloadXML.AddPair) isn't the ideal method. It is fine for a relatively small number of items (it worked fine for my ~100 movie files), but for a huge number of items it will at least freeze VC for a long time.

Here is another example where I scan my mp3 directory and create a payload xml for all the tracks. Here I use Results.MatchtoXML, which is a much more efficient process.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.9-->
<commandGroup open="True" name="get my mp3s" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="277" name="get my mp3 files" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="In this example, I scan my mp3 directory's folders/subfolders. Be careful of which directory you choose here!">
    <action>
      <cmdType>PayloadXML.Clear</cmdType>
      <params>
        <param>payloads\myMp3s.xml</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.Capture</cmdType>
      <params>
        <param>C:\Windows\System32\cmd.exe</param>
        <param>/C dir d:\mp3  /b /s </param>
        <param>True</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RegExTool.Open</cmdType>
      <params>
        <param>True</param>
      </params>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>(.+\\(.+)\.mp3)</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.MatchToXML</cmdType>
      <params>
        <param>payloads\myMp3s.xml</param>
        <param />
        <param>True</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>get my mp3 files</phrase>
  </command>
  <command id="326" name="play mp3" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Playing {PF.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Audio.Play</cmdType>
      <params>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>please play the track</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\myMp3s.xml</payloadFromXML>
  </command>
  <command id="340" name="stop this track" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Audio.Stop</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>stop this track</phrase>
  </command>
</commandGroup>
« Last Edit: January 04, 2016, 12:15:02 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

SteveB69

  • Contributor
  • ***
  • Posts: 72
  • Karma: -1
    • View Profile
Re: Fun with files
« Reply #3 on: December 22, 2015, 07:44:38 PM »
Any chance of a step by step to put this all together? Please?  :)
Chances are I've searched the forum, searched the wiki & scoured You Tube but I'm just to thick to work it out without help!

SteveB69

  • Contributor
  • ***
  • Posts: 72
  • Karma: -1
    • View Profile
Re: Fun with files
« Reply #4 on: January 01, 2016, 10:22:14 PM »
Soz but still not getting this, my mps3s are stored in E:\My Music but I can't figure out where I enter this?
Chances are I've searched the forum, searched the wiki & scoured You Tube but I'm just to thick to work it out without help!

the1Dmitri

  • Jr. Member
  • **
  • Posts: 13
  • Karma: 2
    • View Profile
Re: Fun with files
« Reply #5 on: January 02, 2016, 08:06:21 AM »
Soz but still not getting this, my mps3s are stored in E:\My Music but I can't figure out where I enter this?

 Where is says /C dir d:\mp3  /b /s change d:\mp3 to where your music files are located. In your case it should be /C dir E:\My Music  /b /s

the1Dmitri

  • Jr. Member
  • **
  • Posts: 13
  • Karma: 2
    • View Profile
Re: Fun with files
« Reply #6 on: January 02, 2016, 08:08:44 AM »
Very useful. Thanks nime5ter.  :)

When I first saw the title I thought it said "fun with flies" and my first thought was "ooh a voice controlled fly swatter"  :bonk

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Fun with files
« Reply #7 on: January 02, 2016, 08:25:03 AM »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Fun with files
« Reply #8 on: January 02, 2016, 08:44:38 AM »
Thanks the1Dmitri. :)

Soz but still not getting this, my mps3s are stored in E:\My Music but I can't figure out where I enter this?

It looks like you've since found my answer to this question, which I answered when you asked for assistance in a separate thread: http://voxcommando.com/forum/index.php?topic=2422.msg20895#msg20895

I don't know whether you're subscribed to receive e-mail alerts when people respond to your posts? If not, you may want to enable that option in your forum settings.
« Last Edit: January 02, 2016, 09:06:40 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

SteveB69

  • Contributor
  • ***
  • Posts: 72
  • Karma: -1
    • View Profile
Re: Fun with files
« Reply #9 on: January 03, 2016, 10:43:12 PM »
Yeah thanks nime5ter, way to many emails in my life but for some reason this did end up over 2 topics.
Apologies
Chances are I've searched the forum, searched the wiki & scoured You Tube but I'm just to thick to work it out without help!