Updated Android Lollipop Preview Images – XDA TV

The Android Lollipop Preview Images are now available! That and much more news is … more

Get a Complete Set of Logs with Andy Log

The importance of proper logging is undeniable. No, we’re not talking about lumberjack work. … more

Try Some Android Lollipop Applications on Your Device

Android 5.0 Lollipop has been officially announced and lucky users of Google Nexus 5 … more

AutoCon Manages Your Connections to Perserve Battery Life

As we’ve talked about in the past, battery life is still somewhat of a sore … more
Post Reply

Batch files in Android

OP Anderson2

1st March 2014, 01:09 PM   |  #1  
OP Senior Member
Thanks Meter: 73
 
770 posts
Join Date:Joined: Feb 2012
I've searched Google but have not found a clear answer. I need an *example* of what a simple batch file would look like in Android.

For instance I would like to have a "batch file" to do the following:

1 Search root and its subfolders for files whose names include 'flurry'
2. Delete these files.

I currently use a file manager to do the above, but I would like to automate the process so I could just click on a shortcut to do it. I know how to do that in DOS or Windows but how do I do it in Android?

- What tool would I use to write and run such a "batch file"?
- Where would I learn the proper syntax for batch files in Android?

My devices are rooted and run 4.4.2
Thank you for help suitable for an Android newbie.
1st March 2014, 02:35 PM   |  #2  
Recognized Contributor
Thanks Meter: 1,259
 
3,155 posts
Join Date:Joined: Aug 2012
More
Quote:
Originally Posted by Anderson2

I've searched Google but have not found a clear answer. I need an *example* of what a simple batch file would look like in Android.

For instance I would like to have a "batch file" to do the following:

1 Search root and its subfolders for files whose names include 'flurry'
2. Delete these files.

I currently use a file manager to do the above, but I would like to automate the process so I could just click on a shortcut to do it. I know how to do that in DOS or Windows but how do I do it in Android?

- What tool would I use to write and run such a "batch file"?
- Where would I learn the proper syntax for batch files in Android?

My devices are rooted and run 4.4.2
Thank you for help suitable for an Android newbie.

I thought about writing a batch file for cleaning my intsd of all the junk apps put there. But in the end, I decided to use Tasker instead because it's just easier to maintain. I find myself adding entries all the time, and Root Explorer's text editor is awful.

You can also implement logic that will only delete a folder if children folders are empty.

Easier to make, easier to maintain, no computer or barely usable text editor required.
Last edited by Aerowinder; 1st March 2014 at 02:38 PM.
1st March 2014, 03:02 PM   |  #3  
rootSU's Avatar
Senior Member
Flag Oxenhope, West Yorkshire, UK
Thanks Meter: 12,149
 
23,137 posts
Join Date:Joined: Aug 2010
More
A Batch file is a windows term. Windows "cmd" commands can be batched into a "script" called a "batch file". Meaning a batch file runs cmd commands in sequence as a batch.

Android is Linux kernel based so what you are looking for are 2 things following the same premise as windows.

1) "windows cmd command" becomes "Linux terminal command".

Once you have found the Linux terminal commands to do what you want, you then can look at...

2) "batch file" becomes "bash shell script".

I believe this information should give you the start you're looking for

Sent from my Nexus 5 using Tapatalk

---------- Post added at 03:02 PM ---------- Previous post was at 02:37 PM ----------

Searching root would take some time by the way.... why "root"

Sent from my Nexus 5 using Tapatalk
1st March 2014, 03:44 PM   |  #4  
OP Senior Member
Thanks Meter: 73
 
770 posts
Join Date:Joined: Feb 2012
Quote:
Originally Posted by rootSU

A Batch file is a windows term. Windows "cmd" commands can be batched into a "script" called a "batch file". Meaning a batch file runs cmd commands in sequence as a batch.

Android is Linux kernel based so what you are looking for are 2 things following the same premise as windows.

1) "windows cmd command" becomes "Linux terminal command".

Once you have found the Linux terminal commands to do what you want, you then can look at...

2) "batch file" becomes "bash shell script".

I believe this information should give you the start you're looking for

Sent from my Nexus 5 using Tapatalk

---------- Post added at 03:02 PM ---------- Previous post was at 02:37 PM ----------

Searching root would take some time by the way.... why "root"

Sent from my Nexus 5 using Tapatalk

Thank you. That's helpful.

I started with root because being an android newbie, I was not sure where the flurry files would be and didn't want to miss any. Once I got a handle on that I planned to modify the search path to avoid such a total search.

I'm still feeling my way around Android file structure.
1st March 2014, 03:45 PM   |  #5  
rootSU's Avatar
Senior Member
Flag Oxenhope, West Yorkshire, UK
Thanks Meter: 12,149
 
23,137 posts
Join Date:Joined: Aug 2010
More
Where are these files originating?

Sent from my Nexus 5 using Tapatalk
1st March 2014, 03:51 PM   |  #6  
OP Senior Member
Thanks Meter: 73
 
770 posts
Join Date:Joined: Feb 2012
Quote:
Originally Posted by Aerowinder

I thought about writing a batch file for cleaning my intsd of all the junk apps put there. But in the end, I decided to use Tasker instead because it's just easier to maintain. I find myself adding entries all the time, and Root Explorer's text editor is awful.

You can also implement logic that will only delete a folder if children folders are empty.

Easier to make, easier to maintain, no computer or barely usable text editor required.

That is very helpful. Thank you.

Would you be willing to share your Tasker profiles? I purchased Tasker to support the developer but have not yet learned how to use it. Seems reasonably simple but I'm sure there's a learning curve to avoid unexpected errors. Seeing your profile as an example would give me a headstart.
1st March 2014, 04:01 PM   |  #7  
rootSU's Avatar
Senior Member
Flag Oxenhope, West Yorkshire, UK
Thanks Meter: 12,149
 
23,137 posts
Join Date:Joined: Aug 2010
More
Well tasker has the ability to run tasks such as script > shell - which will run multiple Linux terminal commands as a shell script in much the same way as a bash.sh bash shell script would...

Im not sure if that's what @Aerowinder is specifically referring to but I do this also.

Some script I use bash.sh that I run via tasker and other commands using tasks like this directly...

Sent from my Nexus 5 using Tapatalk
1st March 2014, 04:20 PM   |  #8  
OP Senior Member
Thanks Meter: 73
 
770 posts
Join Date:Joined: Feb 2012
Quote:
Originally Posted by rootSU

Where are these files originating?

Sent from my Nexus 5 using Tapatalk

They are Spyware files created by a number of apps.
If you search on your Android devices you'll probably find you have them too.
Last edited by Anderson2; 1st March 2014 at 04:22 PM.
1st March 2014, 04:30 PM   |  #9  
rootSU's Avatar
Senior Member
Flag Oxenhope, West Yorkshire, UK
Thanks Meter: 12,149
 
23,137 posts
Join Date:Joined: Aug 2010
More
Quote:
Originally Posted by Anderson2

They are Spyware files created by a number of apps.
If you search on your Android devices you'll probably find you have them too.

Android runs sandboxed. Apps cant install themselves without user input. Which means they must be included in apps on the play store. Please name some example apps that do this.

Sent from my Nexus 5 using Tapatalk
1st March 2014, 04:41 PM   |  #10  
Recognized Contributor
Thanks Meter: 1,259
 
3,155 posts
Join Date:Joined: Aug 2012
More
I have some shell commands for FK tunables that I'm currently not using, but my cleanup profile is pretty basic.

Code:
Task: Temporary File Cleanup (18)
	A1: Delete Directory [ Dir:.torque Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A2: Delete Directory [ Dir:AI Factory Stats Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A3: Delete Directory [ Dir:crosswords Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A4: Delete Directory [ Dir:data/flixster Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A5: Delete Directory [ Dir:DCIM/.thumbnails Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A6: Delete Directory [ Dir:DCIM/100ANDRO Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A7: Delete Directory [ Dir:Download Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A8: Delete Directory [ Dir:franco.kernel_updater Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A9: Delete Directory [ Dir:LazyList Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A10: List Files [ Dir:Pictures/reddit_sync Match: Include Hidden Files:eek:ff Variable:%pics Continue Task After Error:eek:n ] 
	A11: If [ %pics1 ! Set ]
	A12: Delete Directory [ Dir:Pictures Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A13: End If 
	A14: Delete Directory [ Dir:SpeedSoftware Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A15: Delete Directory [ Dir:tapatalk4 Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A16: Delete Directory [ Dir:torqueLogs Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A17: Delete Directory [ Dir:TS3 Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A18: Delete Directory [ Dir:Turbo Client Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A19: Delete File [ File:.bugsense Shred Level:0 Use Root:eek:ff Continue Task After Error:eek:n ] 
	A20: Delete Directory [ Dir:Android/data/com.aws.android.elite Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A21: Delete Directory [ Dir:Android/data/com.google.android.apps.googlevoice Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A22: Delete Directory [ Dir:Android/data/com.google.android.gallery3d Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A23: Delete Directory [ Dir:Android/data/com.laurencedawson.reddit_sync.pro Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A24: Delete Directory [ Dir:Android/data/com.quoord.tapatalkHD Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A25: Delete Directory [ Dir:Android/data/com.speedsoftware.rootexplorer Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A26: Delete Directory [ Dir:Android/data/net.zedge.android Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A27: Delete Directory [ Dir:Android/data/_com.maxmpz.audioplayer Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A28: Delete Directory [ Dir:Android/data/com.dropbox.android Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A29: Delete Directory [ Dir:Android/data/com.google.android.apps.maps Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A30: Delete Directory [ Dir:Android/data/com.google.android.googlequicksearchbox Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A31: Delete Directory [ Dir:Android/data/com.google.android.youtube Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A32: Delete Directory [ Dir:Android/data/com.lsdroid.cerberus Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A33: Delete Directory [ Dir:Android/data/com.android.chrome Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ] 
	A34: Delete Directory [ Dir:Android/data/com.android.gallery3d Recurse:eek:n Use Root:eek:ff Continue Task After Error:eek:n ]
That smiley bug is really annoying.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Nexus 5 Q&A, Help & Troubleshooting by ThreadRank