1 Reply Latest reply on Mar 1, 2015 3:23 AM by Iftach Priel

    dispatch -> delete file in folderpath

    Mario Zahren

      Hello,

       

      I´m trying to delete a file in a specific Folderpath with dispatch.

       

      e.g.

      D:\vault\Folder1\Folder2\Folder3\myFolder\Folder4\...

       

      The Foldernames before and after "myFolder" are always different. If the File, I want to delete, is in any Folder under or in "MyFolder" then deleting should be possibel otherwise not.

      So I´m trying to extract the string "myFolder" from the Folderpath like that:

       

      IF %PathToSelectedFile% != %RootFolderPath%\%\myFolder\% NO_CASE THEN GOTO Exit

       

      but it doesn´t work.

       

      Thanks for help in advance.

       

      Cheers

      Mario

        • Re: dispatch -> delete file in folderpath
          Iftach Priel

          Hi Mario,

           

          Yes, dispatch doesn't always like wildcards. No use trying * or $ either.

           

          There is a way around it though. Its not very elegant, but it works:

           

          1. Create a dispatch variable, type static string. Call it FindMyFolder (or anything else)
          2. In the value field type: Find(%PathToSelectedFile%,myfolder)
          3. In your jump command: IF %FindMyFolder% = -1 NO_CASE THEN GOTO Exit

           

          That's it.

           

          "find" looks for the location of a specific sub-string of characters (myfolder) inside a different string of characters (the path). It brings back a number, that represent the beginning of the sub-string (first character is 0). For example, find(Abracadabra,cad) will give you 4.

          The nice thing is that if it can't find the sub-string at all, it brings back the value -1. This way you can use find as something similar to the contain and not contain we all like in conditions.

           

          Hope this helps,

           

          Iftach