Need easier way to set filepath & filename to a variable

1,557 views
Skip to first unread message

MonkeyThumper

unread,
Aug 15, 2013, 12:19:46 PM8/15/13
to tas...@googlegroups.com
Hi everyone,

I've searched, but had no luck finding a solution...

I want to set a variable to the filepath & filename of a mp3 file.  I use this variable in other tasks for alerts and such, but I like to change it once in a while, and by having the variable, I only have to change it in one place for it to affect all of my other alerting tasks.

I can, and have been, doing this manually, by typing the info into the Variable Set action.  This is a pain sometimes to get the filepath & filename copied/pasted.  

So, I would like the process of changing this variable to be made easier by having the option to be able to browse for the mp3 file, and select it, and have that become the new value for my Variable Set action.  

Is this currently possible, or is it something that can be added within Tasker?

Thanks,
Butch




Brandon Horwath

unread,
Aug 15, 2013, 12:52:31 PM8/15/13
to tas...@googlegroups.com
Is this currently possible,

Nope. Not to my knowledge.

or is it something that can be added within Tasker?

Yes. In a multitude of various ways. That said, determining the condition to overwrite the variable value would be dictated solely by the process you interact with your device to determine a new value. Then translating that process into a series of conditions that results in overwriting the variable with the desired value.

Your main issue will be getting tasker to recognize the file path of the media playing, which MIGHT be possible if defined manually into tasker and some kind of regular expression applied regarding song, artist, album title and file path name. If not the case, maybe the plugin, media utilities, can do so.

Getting tasker to associate the correct file path to the media playing will be the biggest hurdle. Once you can do that you can re-set the desired variable to the new file path based on nearly any action.

Maybe something as simple as playing the same song twice in a row will make tasker re-write the desired variable to the song's file path.

MonkeyThumper

unread,
Aug 15, 2013, 1:02:35 PM8/15/13
to tas...@googlegroups.com
Hi Brandon,

Thanks for replying but I think you may be over thinking what I am trying to do. Let me clarify some...

I only want the variable value to change when I want it to. I am still wanting to go directly into Tasker to change the value. It has nothing to do with a current song playing, nor with one I played recently.

I would like to see the option to browse for a file, directly from the place I setup the variable within Tasker. When I browse and select the file, the filepath and filename would be auto filled as the value for the variable setting I am currently working on.

Does that make a little more sense?

Thanks for helping.

Butch


Mike L

unread,
Aug 15, 2013, 1:19:33 PM8/15/13
to tas...@googlegroups.com
Using the "List File" action will give you a list of files, and their full paths as an array. You could then search through your list to find the song or whatever you are looking for.

You could display this as a scene, using "List Files" to fill a menu element. 

MonkeyThumper

unread,
Aug 15, 2013, 1:45:56 PM8/15/13
to tas...@googlegroups.com


Hi Mike,

I will look at the List File action, but I think that wouldn't save/set the variable so that it would survive a reboot of the phone.  

Currently, I set a variable named "%NOTIFY_SOUND1" within Tasker, that is set at Device Boot in a Profile.

I'm thinking that the List File action would have to be done each time I reboot the phone in order to set my variable.  I will have to test this when I get a few minutes though.

Thanks,
Butch



Mike L

unread,
Aug 15, 2013, 1:52:49 PM8/15/13
to tas...@googlegroups.com
A global variable (uppercase) will survive a reboot and hold it's info

TomL

unread,
Aug 15, 2013, 2:06:34 PM8/15/13
to tas...@googlegroups.com
It's not quite what you want, but if you install something like the app !Share or ClipIntent, you'll get an extra menu option in your Share or SendTo menu.  Then you can open any file explorer app you want, go to the dir listing, long click on the file or folder, select Share or SendTo and then select Copy filepath to clipboard.

Tom

Brandon Horwath

unread,
Aug 15, 2013, 2:32:29 PM8/15/13
to tas...@googlegroups.com
It's not quite what you want, but if you install something like the app !Share or ClipIntent, you'll get an extra menu option in your Share or SendTo menu. Then you can open any file explorer app you want, go to the dir listing, long click on the file or folder, select Share or SendTo and then select Copy filepath to clipboard.

... really?!

This will make that EASY if I have a chance to play with that today!

Will also help me add some profile tasks to my %CLIP set profile! It should be a simple matter of adding, if %CLIP ~R */*.* then set %var to %CLIP (follow me on this OP?)

:-)

Thanks!

Mike L

unread,
Aug 15, 2013, 2:46:36 PM8/15/13
to tas...@googlegroups.com
On Thursday, August 15, 2013 2:32:29 PM UTC-4, Brandon Horwath wrote:
It's not quite what you want, but if you install something like the app !Share or ClipIntent, you'll get an extra menu option in your Share or SendTo menu.  Then you can open any file explorer app you want, go to the dir listing, long click on the file or folder, select Share or SendTo and then select Copy filepath to clipboard.


ES File Explorer does this as well, long press, menu, properties 

Brandon Horwath

unread,
Aug 15, 2013, 2:58:42 PM8/15/13
to tas...@googlegroups.com
Turns out, using x-plore with DVR (Desktop VisualizeR) will actually save the file path location as an intent in the clipboard for use in DVR. (Which does act as a tasker plugin, just not sure how)

MonkeyThumper

unread,
Aug 15, 2013, 3:13:19 PM8/15/13
to tas...@googlegroups.com
Mike L:  ES File Explorer is how I have been doing it lately.  It made it easier, but I was hoping for a solution from within Tasker.  Just always looking for easier ways to do even the simple things...  Thanks for the recommendation though.

TomL:  I was previously using an app that did what you describe, until I found that I could grab it quicker with ES File Explorer.  Thanks.

Brandon:  Yes, I follow that perfectly.  It makes sense, and I will try that myself in a few.  Shouldn't be too hard to setup and test.  Thanks for the example.  Once I read the "if %CLIP ~R */*.*" part, then my lightbulb came on for the solution.


Of course...even if this works, I would still love to see the option within Tasker to let me browse the file folders and select a file to fill in for a variable.  It would just be nice to be able to do it all directly within Tasker.  But in the meantime, I think we may have a good workaround.  Will know more soon...off to test now.

Butch

MonkeyThumper

unread,
Aug 15, 2013, 3:53:08 PM8/15/13
to tas...@googlegroups.com
Well crud...

I'm using Android 4.3 (Cyanogenmod) and ES File Explorer crashes when I click on the button to copy the full path to the clipboard.  This is the first time I have tried this in ES since I converted to 4.3 last week, and it seems to be broke.  Anyone have 4.3 and ES to try it?

I then tried using the Cyanogenmod File Explorer, but I can't find a way to copy the filepath & filename to the clipboard.  Anyone else using the Cyanogenmod File Explorer that can try it out?

Going to try to setup my SendTo menu option again and see if that will let me do it.  

I haven't looked at x-plore yet...was trying to use what I've already got first.

Thanks,
Butch

Bob Hansen

unread,
Aug 15, 2013, 4:11:29 PM8/15/13
to tas...@googlegroups.com
There is a known bug in the clipboard function for android 4.3 that causes apps to crash. For more info set this http://www.androidpolice.com/2013/08/08/bug-watch-android-4-3-running-an-app-that-watches-the-clipboard-will-cause-other-apps-to-crash-when-you-copy-from-them/

MonkeyThumper

unread,
Aug 15, 2013, 4:12:39 PM8/15/13
to tas...@googlegroups.com
Seems to be a problem with 4.3.

I've tried 4 different apps to get the info copied to the clipboard, and they all crash.  Reports were sent for the crashes...

I will need to post this issue to XDA to see if anyone else using 4.3 is having the issue.

I really think that the solution offered up by Brandon will work, once I can copy stuff to my clipboard again.

Butch

Rich D

unread,
Aug 15, 2013, 4:13:50 PM8/15/13
to tas...@googlegroups.com

I personally have not found a file explorer that allows for fast easy searches so I made my own with tasker. It would take some work but for what you want to do it might be worth it.  You basically use a text edit box to input your search criteria and with every character you input the search is refined and listed in a menu. It works very fast and accurate .. let me know if you are interested in that approach....

Rich..

MonkeyThumper

unread,
Aug 15, 2013, 4:14:13 PM8/15/13
to tas...@googlegroups.com
Thanks Bob.  You posted when I was typing my message out.  I will look at this now.  Thank you very much.

MonkeyThumper

unread,
Aug 15, 2013, 4:20:50 PM8/15/13
to tas...@googlegroups.com
Rich D:  

I just found an app that I really like for this exact purpose:

Very simple, very fast....except for the 4.3 clipboard problem I am running into.

Brandon Horwath

unread,
Aug 15, 2013, 4:39:47 PM8/15/13
to tas...@googlegroups.com
Bob, kudos on recalling the crash issue. That really seems to be the root of the difficulty experienced here.

Rich,

let me know if you are interested in that approach....

I am!
But really more as a learning exercise so, there's no real need to go into it if you'd rather not.

Rich D

unread,
Aug 15, 2013, 5:22:10 PM8/15/13
to tas...@googlegroups.com

> I am!
> But really more as a learning exercise so, there's no real need to go into it if you'd rather not.

I will see if I can pull it out of the project it is in. The project is for storing pics in folder names, but should be easy to adapt to what you are looking for... 

As for your current problems with the copy/paste. Another approach could be to share the file.   You should be able to use The plug in "Auto Share"  to retrieve the file path from the share...

Rich D

unread,
Aug 15, 2013, 5:28:39 PM8/15/13
to tas...@googlegroups.com

> > I am!
> > But really more as a learning exercise so, there's no real need to go into it if you'd rather not.
>
> I will see if I can pull it out of the project it is in. The project is for storing pics in folder names, but should be easy to adapt to what you are looking for... 

BTW.. could you post a example of a file name of your mp3's and how you search for them. I am just curious if it is a short list that you just scroll through in one folder or do you use a folder hierarchy and look through several folders??

Brandon Horwath

unread,
Aug 15, 2013, 5:35:08 PM8/15/13
to tas...@googlegroups.com
You should be able to use The plug in "Auto Share" to retrieve the file path from the share...

I've been playing around with that and no luck.

I imagine there HAS to be a way to use file magic to get this info without using clipboard... but cannot figure out how.

Rich D

unread,
Aug 15, 2013, 6:34:04 PM8/15/13
to tas...@googlegroups.com

> You should be able to use The plug in "Auto Share"  to retrieve the file path from the share...
>
> I've been playing around with that and no luck.

I just tried it and it worked on my device...
I have a moto droid 4 running 2.3.6.   Rooted
Version 1.6u1m

>
> I imagine there HAS to be a way to use file magic to get this info without using clipboard... but cannot figure out how.

I think it is possible with file magic but it is a very very basic browser. 

Brandon Horwath

unread,
Aug 15, 2013, 7:19:36 PM8/15/13
to tas...@googlegroups.com
My flashed AutoShare Intercept value contains no contents for file path info.

In fact, the received share toast flashed only contains the package name, and the app accessing the share.

However, in my autoshare settings I only have intercept enabled, not autoshare or command.

Should I be using something different?

Rich D

unread,
Aug 15, 2013, 8:05:12 PM8/15/13
to tas...@googlegroups.com

>
> However, in my autoshare settings I only have intercept enabled, not autoshare or command.
>
> Should I be using something different?

Both command and autoshare worked for me, I did not try intercept ..

Rich D

unread,
Aug 15, 2013, 10:38:59 PM8/15/13
to tas...@googlegroups.com

OK here is a example of what i was talking about..

1. Import file as project
2. Go to to tasks and manually run the "start" task
3. Input the file path of the folder containing the files to be searched ( this version will only search 1 folder IE it is not recursive ) your path should look similar to this..

/mnt/sdcard-ext/work files/A Work excel/

4. Hit the green check mark
5. Tap the blue text box in the upper right, Start typing what ever you think will be contained in the file name. The first 2 characters entered will display all files "starting" with those 2 characters. After the third character it will search for the string anywhere in the file name. The results are displayed in the menu on the left. You can scroll the menu.
6. Select the file you want..

Let me know if it works for you...

Test_File_Picker.prj.xml

Rich D

unread,
Aug 16, 2013, 9:06:48 AM8/16/13
to tas...@googlegroups.com


On Aug 15, 2013 10:38 PM, "Rich D" <ricp...@gmail.com> wrote:
>
> OK here is a example of what i was talking about..

Oops... the last file I posted contained alot of the original project. I thought i had deleted all of that out but it decided to go back in.  Here is a simplified version... I hope..

Test_File_Picker2.prj.xml

Brandon Horwath

unread,
Aug 16, 2013, 12:45:18 PM8/16/13
to tas...@googlegroups.com
Whoa. Way easier to understand!

Rich D

unread,
Aug 16, 2013, 12:56:41 PM8/16/13
to tas...@googlegroups.com

>
> Whoa. Way easier to understand!

Yea... sorry bout that... I thought it would only export what is in the project but apparently tasker exports everything linked with it. I needed to actually delete all that stuff from tasker ..

The scene could use some work but it is just something quick I came up with..

MonkeyThumper

unread,
Aug 18, 2013, 6:54:21 PM8/18/13
to tas...@googlegroups.com

Just an update to some of my testing of using the clipboard and having Tasker monitor it to set a variable for me.

As we discussed earlier on, Android 4.3 has a bug with the clipboard.  That part is basically understood.

I have found that even though the bug exists, the info is still actually copied to the clipboard anyway, but the app I am using crashes.  I've proven it by pasting the info elsewhere after the crash, and what I need is there, so it is just an app crash, and not something stopping the ability to actually copy something into the clipboard.

So...the problem then seems to be that Tasker is not detecting that the variable %CLIP matches Regex " */*.* ", so that it could run the task that sets %NOTIFY_SOUND1 to equal %CLIP.  If I run that task manually, it sets it fine.  Also, I have even taken the Regex part out of the Profile, so that it would run the task if %CLIP was set to anything, but it still doesn't work.

It is almost like %CLIP isn't actually being monitored for any value.  As I said, I think this is due to the bug, but just wondering if anyone can confirm that is part of what the bug does.  

Of course, I feel this is part of the 4.3 clipboard bug, but I'm just wondering if anyone is able to explain why the bug would not let Tasker detect that %CLIP matches Regex */*.* ? 

Everything I read on the Google Bug Reports for this don't go into that great of a detail of what to expect from the app that is doing the actual monitoring of the clipboard.  It only details that a monitoring app causes the crash of the app copying something into the clipboard.

At this point, I'm not looking for other options on how to do this (except for the ability to do it directly from within Tasker on the Variable Set page...), because I feel that grabbing the %CLIP is a great and simple workaround for my situation, as soon as the 4.3 bug is fixed.  I'm just trying to make sure that Tasker is working correctly with the %CLIP to begin with, since that variable is changing, but not being picked up as a change by the Tasker Profile.

Thanks everyone!

Butch


Brandon Horwath

unread,
Aug 18, 2013, 8:25:25 PM8/18/13
to tas...@googlegroups.com
Try this...

Profile: Variable Set - CLIP ~ * (53)
Event: Variable Set [ Variable:%CLIP Value:* ]

Enter: Clip Check (25)
Alert, flash: Clipboard set

Does the alert flash?

MonkeyThumper

unread,
Aug 18, 2013, 9:21:48 PM8/18/13
to tas...@googlegroups.com
Tried it. It didn't flash the message. I actually had tried that when I messing with it the other day, but I did just try it again to make sure I did it right. No luck.

It is like the bug interferes with Tasker being able to detect that %CLIP has been set or changed.

Any other suggestions?

Brandon Horwath

unread,
Aug 18, 2013, 10:22:22 PM8/18/13
to tas...@googlegroups.com
Leave that profile enabled.

Now, create a task with the only action, set clipboard to some value.

If tasker sets the clipboard, does it recognize the clipboard is set?

MonkeyThumper

unread,
Aug 18, 2013, 11:08:49 PM8/18/13
to tas...@googlegroups.com
I setup a task to set the variable %CLIP to "X", but I get an error that says Built in variables cannot be modified.

Or is there some other way you meant for me to change the clipboard using Tasker?

Brandon Horwath

unread,
Aug 18, 2013, 11:33:42 PM8/18/13
to tas...@googlegroups.com
Set Clipboard (32)
A1: Set Clipboard [ Text:X Add:Off ]
A2: Flash [ Text:%CLIP Long:Off ]

Set Clipboard is found under action, misc. Set Clipboard

Brandon Horwath

unread,
Aug 18, 2013, 11:34:52 PM8/18/13
to tas...@googlegroups.com
Both command and autoshare worked for me, I did not try intercept ..

Yep. Possible solution there!

MonkeyThumper

unread,
Aug 18, 2013, 11:50:14 PM8/18/13
to tas...@googlegroups.com
Thanks. I did not know that was there.

I set it up and get an error. (how do I grab the text from the last toast message?)

Error says:
Code 3: java.lang.illegalstateexception:
beginbroadcast() called while already in a
broadcast

MonkeyThumper

unread,
Aug 18, 2013, 11:57:32 PM8/18/13
to tas...@googlegroups.com
I meant to finish by saying that I will look into that error more tomorrow. It is time for bed now.

Thanks for your help so far though.

Butch

MonkeyThumper

unread,
Aug 19, 2013, 9:36:13 AM8/19/13
to tas...@googlegroups.com
That error is caused directly by the 4.3 clipboard bug.  I have found numerous webpages discussing the bug, and this error shows up in their logs.

Oh well...Google says they have a fix for this.  Now we wait for them to actually release it so that Cyanogenmod can get it added to one of their nightly releases.

Once the fix is applied, I will try to remember to come back to this thread and report how things work for me then.

Thanks to everyone who tried to help, and the great "workaround" options that were suggested.  

Butch

Rich D

unread,
Aug 19, 2013, 10:12:06 AM8/19/13
to tas...@googlegroups.com

> At this point, I'm not looking for other options on how to do this (except for the ability to do it directly from within Tasker on the Variable Set page...)

From what I understand you would like to be able to set a file (mp3) name and path to a global variable for use in other tasks.

I still believe a simple scene / menu that lists your mp3's would be the best route. Every time I have used tasker to replace what other apps do, the tasker version is always much better and able to be customized for my use. I am not sure if you fully understand the way it would work and I realize you said you do not want other options but just to be clear the way this would work would be...

1. Tap tasker shortcut from your home screen.
2. This would show a menu Listing all of your mp3's, Sorted anyway you would like.
3. Tap on the file name you want And this will set the global variable for your mp3.

All that being said if you do not want to wait for the fix for the clipboard bug the next best thing or perhaps even better would be the "autoshare" add on.  I think the advantage to using the share is that most if not all file browsers will do a share where as some might not let you copy the file name easily.  

Rich..

MonkeyThumper

unread,
Aug 20, 2013, 9:03:36 AM8/20/13
to tas...@googlegroups.com
Hi Rich,  (Sorry for the slow response...I thought I sent this yesterday, but found it waiting on me this morning)

I tried the "autoshare" way, but the 4.3 bug still seems to kick in.  That was the first time I played with autoshare, and I do like that.  Have to play with that more later.

I did look at your way of doing it the other day.  I downloaded and imported it.  I ran the start task, and I put in my input file path, which then it showed me the list of files,  I put a * in for the list of files, and selected the one that I wanted, but then I was lost at that point.  The file was highlighted, and I see a quit button, but I wasn't sure what I needed to do next, and I wasn't positive what variable it should have been assigned to either.   Honestly, I gave up with it at that point as I considered it just to difficult to figure out.  I'm definitely not an expert with Tasker, and your task is just too advanced for me to understand at this point to make it work for my needs.  It looked very interesting, but I just couldn't understand enough of it.

Thanks,
Butch

MonkeyThumper

unread,
Aug 20, 2013, 9:56:06 AM8/20/13
to tas...@googlegroups.com

Something new to add to this.

When trying out the solution that Brandon was helping me with, I was trying to figure out why Tasker profile wasn't detecting the filepath/filename variable value, so that it could kick off the task.

A couple of issues came up.

1 - I needed the Regex to match as ^/.*\.... instead of the */*.* that was suggested.  

2 - I have to cycle the screen off and on (using the power button), to get Tasker to then detect that %CLIP had changed.

So, with that straightened out, I was then able to copy the filepath/filename to %CLIP, the app would crash as expected, and then I would just cycle the screen off/on, and Tasker would then run my task to copy %CLIP to my %NOTIFY_SOUND1 variable.  I then set %CLIP to "XxX", just to clear the filepath/filename out of the clipboard.  I have a couple of Flash statements just so I can see what is happening.

Here is the info:

Profile: Set Sound Var (51)
State: Variable Value [ Name:%CLIP Op:Matches Regex Value:^/.*\.... ]
Enter: Set Sound Vars (21)
A1: Variable Set [ Name:%NOTIFY_SOUND1 To:%CLIP Do Maths:Off Append:Off ] 
A2: Flash [ Text:%NOTIFY_SOUND1 - - - %CLIP Long:On ] 
A3: Set Clipboard [ Text:XxX Add:Off ] 
A4: Flash [ Text:%NOTIFY_SOUND1 - - - %CLIP Long:On ] 


 Any suggestions about me needing to cycle the screen off/on to get Tasker to read that %CLIP has a value set?


Thanks,

Butch


MonkeyThumper

unread,
Aug 20, 2013, 10:24:29 AM8/20/13
to tas...@googlegroups.com
Also...I just figured out that I need to change my Regex to add a $ to the end of it, like this now:   ^/.*\....$

Otherwise, I pick up filepaths/filenames with a period in the middle of them by accident.

Rich D

unread,
Aug 20, 2013, 12:47:06 PM8/20/13
to tas...@googlegroups.com

> I tried the "autoshare" way, but the 4.3 bug still seems to kick in.  That was the first time I played with autoshare, and I do like that.  Have to play with that more later.

Well that disappointing ...

>
> I did look at your way of doing it the other day.  I downloaded and imported it.  I ran the start task, and I put in my input file path, which then it showed me the list of files,  I put a * in for the list of files, and selected the one that I wanted, but then I was lost at that point.  The file was highlighted, and I see a quit button, but I wasn't sure what I needed to do next, and I wasn't positive what variable it should have been assigned to either.   Honestly, I gave up with it at that point as I considered it just to difficult to figure out.  I'm definitely not an expert with Tasker, and your task is just too advanced for me to understand at this point to make it work for my needs.  It looked very interesting, but I just couldn't understand enough of it.

Sorry about that... when I cleaned it up and re-posted it I did not fix the output. It should have just gave you a flash telling you a variable had been set.. It was only to give you a idea on how it would work.  If all of your mp3's are located in one folder then it would be very easy to customize this for you.. just let me know if you are interested ..

Since I posted this I have been trying .... to get it to work recursively ( look in all folders in the given path)  but I am having some problems so far.. so the recursive version is a ways of...... :(   

MonkeyThumper

unread,
Aug 20, 2013, 1:28:21 PM8/20/13
to tas...@googlegroups.com
No problem.  You tried to help, which was great.  It was just a bit over my head.  I wasn't getting the flash to tell me a variable had been set, which is why I was confused about what should have happened next.  

My mp3 are located in a few different locations (currently 3 different folders, and they are not subfolders of each other), so being able to browse through the file structure would be important to me with any solution.  Thanks for the offer to customize something though.  

I feel I have a "workaround solution" for the time being, even though I have to cycle the screen off/on to get Tasker to read the %CLIP variable.  This isn't something I do daily, but just something I change once in a while when I am in the mood for a different notification sound to be set.  

Thanks!
Butch
Reply all
Reply to author
Forward
0 new messages