1. You want that $100.00 in your pocket or an Amazon Fire TV don't you? Well here's the deal. With our new updated look we are in desperate need of an updated logo. The 'old' one has certainly served us well, but it's time. Find all the details here: bit.ly/1q0k6Wa
  2. DroidForums.net is currently undergoing a major software upgrade. If you are experiencing any problems logging in please: Contact Us

In search of simple script

Discussion in 'Android Hacks and Help' started by hahn, Jun 7, 2010.

  1. hahn
    Offline

    hahn New Member

    Joined:
    Mar 1, 2010
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    0
    Sorry if posted in the wrong place. :confused:

    All I want is to have a script that I can use with a Script Scheduler I found that will move all the contents from one folder in the /sd to another folder in the /sd

    The idea is that every night, it will run and all the various apps I have that just love to download pictures and music and video in their own little folder will be redirected into one specific folder of my choosing.

    For the life of me I cannot find someone that has come up with this idea; though I'm almost positive that it would be relatively simple and immensely useful. Especially once dropbox or some other similar app allows a local folder to sync contents over wifi or edge. If someone has and I failed to find it my apologizes, but I have searched for the last 3 days. Hell I even tried going into the andorid developer forum from google to try and learn how to do it myself. Turns out, this isn't high school C++ from 2001. Much respect.
  2. LrdElderon
    Offline

    LrdElderon New Member

    Joined:
    Jan 10, 2010
    Messages:
    489
    Likes Received:
    0
    Trophy Points:
    0
    well does this script scheduler let you use bash shell scripts?

    assuming the timer is in the app itself the script is just as simple as

    cp /sdcard/foldername/* /sdcard/newfolder/

    or

    cat /sdcard/foldername > /sdcard/newfolder/

    I think that would work.
  3. hahn
    Offline

    hahn New Member

    Joined:
    Mar 1, 2010
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    0
    It should. This is the program I found (I knew it was a simple command - thanks).

    Scheduled Scripting App - Scheduled Reboots, etc... Phone Prioritizer App - xda-developers

    So basically in Notepad++ I wrote the following into the script.txt:

    busybox renice 5 `pidof com.google.process.gapps`
    busybox renice -18 `pidof com.android.phone`
    busybox renice -18 `pidof mediaserver`
    busybox renice -18 `pidof mediaserver`
    busybox renice -16 `pidof com.android.launcher`
    busybox renice -15 `pidof com.htc.music`
    busybox renice -15 `pidof com.android.music`

    su

    boolean mExternalStorageAvailable = false;
    boolean mExternalStorageWriteable = false;
    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {

    // We can read and write the media
    mExternalStorageAvailable = mExternalStorageWriteable = true;
    // Your Code
    // Suggestion #2 - cat /sdcard/test/from > /sdcard/test/to/
    cp /sdcard/test/from/* /sdcard/test/to/
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {

    // We can only read the media
    mExternalStorageAvailable = true;
    mExternalStorageWriteable = false;
    } else {

    // Something else is wrong. It may be one of many other states, but all we need
    // to know is we can neither read nor write
    mExternalStorageAvailable = mExternalStorageWriteable = false;
    }


    I don't understand the busybox portion but it was originally in the script so I imagine it has to do with the scheduler app I'm using. The mExternalStorageAvailable if/else statements I got from andorid development forum and its supposed to just make sure that the sdcard is available for read/write.

    I'm going to try a few versions to see if i can get it to work.

    Thanks for the help. I will change the command from 'cp' to 'mv' after I get it to work with the scheduler. I tried cp in the terminal and it copied the files perfectly, but I rather cut and paste so there aren't duplicates.
  4. hahn
    Offline

    hahn New Member

    Joined:
    Mar 1, 2010
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    0
    [Resolved]

    Okay. After much investigation and little knowledge. I finally got it to work.

    I had to abandon the portion seeking to establish whether the SD Card is mounted, I will have to just deal with the fact that at times, the program will try to run and fail miserably. I left in the busybox portion, still don't know what it does, but it harms nothing that I can tell.

    I wrote the following to organize the folders:

    {
    busybox renice 5 `pidof com.google.process.gapps`
    busybox renice -18 `pidof com.android.phone`
    busybox renice -18 `pidof mediaserver`
    busybox renice -18 `pidof mediaserver`
    busybox renice -16 `pidof com.android.launcher`
    busybox renice -15 `pidof com.htc.music`
    busybox renice -15 `pidof com.android.music`
    {
    mv /sdcard/com.tokasiki.android.voicerecorder/*.3gp /sdcard/"Computer Data"/"Voice Recorder"/ ;

    mv /sdcard/DCIM/Camera/*.jpg /sdcard/"Computer Data"/Pictures/ ;

    mv /sdcard/DCIM/Camera/*.3gp /sdcard/"Computer Data"/Video/ ;

    cp /sdcard/download/* /sdcard/"Computer Data"/Downloads/ ;

    mv /sdcard/FxCamera/* /sdcard/"Computer Data"/Pictures/ ;

    mv /sdcard/iMusic/*.mp3 /sdcard/"Computer Data"/Music/ ;

    mv /sdcard/mp3/* /sdcard/"Computer Data"/Music/ ;

    mv /sdcard/"Music Junk"/* /sdcard/"Computer Data"/Music/ ;

    mv /sdcard/TubeDownloader/* /sdcard/"Computer Data"/Video/ ;

    mv /sdcard/Video/* /sdcard/"Computer Data"/Video/ ;
    }
    }

    I use gScript from the market to get a shortcut on the main menu & Script Scheduler to have it run once a day. I checked, it works. It comes back with an error message in GScript when the directory is empty, but other than that it seems really clean.

    Thanks for the help above it got me a long way to understanding how to do the rest. Great starting point.
  5. Bear in NM
    Offline

    Bear in NM Active Member

    Joined:
    Nov 12, 2009
    Messages:
    1,389
    Likes Received:
    1
    Trophy Points:
    38
    Hahn,

    In this thread, a couple of doors down in this forum there is a link to explaining the nice command. Esentially it changes the priority level of specific applications. My logical assumption is that by leaving these commands in, you are altering the priority level of the apps in the list. This is if these apps even exist on your phone/rom setup.

    http://www.droidforums.net/forum/dr...rocess-priority-prevent-app-being-killed.html

    I am not sure I would necessarily leave them in, unless you understand what the priority change might do to your phone and your rom. Conversely, you can use these commands to positively affect your phone in a way that you would want.

    I have been playing with terminal scripts for a while, and your thread has now got me interested in more base/system level hacks, especially at root. Thanks for the post.

    Craig
Search tags for this page

android busybox renice

,

android renice script

,
android scripts busybox comands
,
android shortcut busybox script
,
busybox renice -18 `pidof com.android.phone` error
,
busybox script android
,
busybox scripts android
,

renice android

,
renice rc script android
,
renice script anroid
,
script renice android
,
script renice android shell