Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,813,710 Members 39,417 Now Online
XDA Developers Android and Mobile Development Forum

Batch files in Android

Tip us?
 
Anderson2
Old
#1  
Senior Member - OP
Thanks Meter 73
Posts: 763
Join Date: Feb 2012
Default Batch files in Android

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.
 
Aerowinder
Old
(Last edited by Aerowinder; 1st March 2014 at 02:38 PM.)
#2  
Recognized Contributor
Thanks Meter 1,231
Posts: 3,110
Join Date: Aug 2012
Quote:
Originally Posted by Anderson2 View Post
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.
 

Google Firmware: Google
USB Drivers: Google | Mirror
ADB+ADB Drivers: 19.0.2 (4.4.4) + Koush Universal ADB Drivers

TWRP Official: hammerhead | flo
TWRP Holofied: hammerhead | flo

Gapps: jajb

Superuser: Chainfire | Mirror
 
rootSU
Old
#3  
rootSU's Avatar
Senior Member
Thanks Meter 11,449
Posts: 22,484
Join Date: Aug 2010
Location: Oxenhope, West Yorkshire, UK
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
Want to root/unroot? All important guides and info threads are contained within the "Sticky Roll-up" thread in General. Click the link below to get there!

**Sticky Roll-up: All Guides snd Info Threads linked here**



Philz Touch Recovery with passkey secure lock

I do NOT reply to support queries over PM.
 
Anderson2
Old
#4  
Senior Member - OP
Thanks Meter 73
Posts: 763
Join Date: Feb 2012
Quote:
Originally Posted by rootSU View Post
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.
 
rootSU
Old
#5  
rootSU's Avatar
Senior Member
Thanks Meter 11,449
Posts: 22,484
Join Date: Aug 2010
Location: Oxenhope, West Yorkshire, UK
Where are these files originating?

Sent from my Nexus 5 using Tapatalk
Want to root/unroot? All important guides and info threads are contained within the "Sticky Roll-up" thread in General. Click the link below to get there!

**Sticky Roll-up: All Guides snd Info Threads linked here**



Philz Touch Recovery with passkey secure lock

I do NOT reply to support queries over PM.
 
Anderson2
Old
#6  
Senior Member - OP
Thanks Meter 73
Posts: 763
Join Date: Feb 2012
Quote:
Originally Posted by Aerowinder View Post
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.
 
rootSU
Old
#7  
rootSU's Avatar
Senior Member
Thanks Meter 11,449
Posts: 22,484
Join Date: Aug 2010
Location: Oxenhope, West Yorkshire, UK
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
Want to root/unroot? All important guides and info threads are contained within the "Sticky Roll-up" thread in General. Click the link below to get there!

**Sticky Roll-up: All Guides snd Info Threads linked here**



Philz Touch Recovery with passkey secure lock

I do NOT reply to support queries over PM.
 
Anderson2
Old
(Last edited by Anderson2; 1st March 2014 at 04:22 PM.)
#8  
Senior Member - OP
Thanks Meter 73
Posts: 763
Join Date: Feb 2012
Quote:
Originally Posted by rootSU View Post
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.
 
rootSU
Old
#9  
rootSU's Avatar
Senior Member
Thanks Meter 11,449
Posts: 22,484
Join Date: Aug 2010
Location: Oxenhope, West Yorkshire, UK
Quote:
Originally Posted by Anderson2 View Post
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
Want to root/unroot? All important guides and info threads are contained within the "Sticky Roll-up" thread in General. Click the link below to get there!

**Sticky Roll-up: All Guides snd Info Threads linked here**



Philz Touch Recovery with passkey secure lock

I do NOT reply to support queries over PM.
 
Aerowinder
Old
#10  
Recognized Contributor
Thanks Meter 1,231
Posts: 3,110
Join Date: Aug 2012
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.
 

Google Firmware: Google
USB Drivers: Google | Mirror
ADB+ADB Drivers: 19.0.2 (4.4.4) + Koush Universal ADB Drivers

TWRP Official: hammerhead | flo
TWRP Holofied: hammerhead | flo

Gapps: jajb

Superuser: Chainfire | Mirror

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes