Results 1 to 4 of 4

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Mobile Terminal help

  1. #1
    Default Mobile Terminal help
    Couldn't find a proper forum, so mods/admins please move this if needed.

    I need help making a script for mobile terminal to help expedite a task I do repetitivel .

    I have two similar files in a folder (black.png and [email protected]). I need to copy them twice and rename the copies to other things. So I would either need it to copy the file as the other name or to have the script copy them, then search for "black (1).png", "black@2x (1).png", "black (2).png", "black@2x (2).png" and rename them to silver.png, [email protected], etched.png, and [email protected] respectively.


    I can get around in Mobile Terminal and I can use scripts that are there, I'm just not terribly familiar with bash. If someone makes me a example to check for a file name (or file size), copy files, and rename them, I can modify it for what I need specifically.
    Last edited by citric; 03-30-2013 at 10:22 AM.

  2. #2
    Well I kind of figured out a way to do what I'm trying to do, but there would definitely be a more elaborate way do it if anybody wants to help

  3. #3
    #!/bin/bash

    cp black.png etched.png
    cp black.png silver.png
    echo "Copied black.png"

    cp [email protected] [email protected]
    cp [email protected] [email protected]
    echo "Copied [email protected]"

    echo "Respringing"
    respring
    This is what I have come up with and it works well, but I'm going to try to make it automated going through folders to check how many files are already there and which file is bigger

  4. #4
    #!/bin/bash

    filearray=( *.png )

    LINES=$(wc -l filename); echo ${LINES}
    fsize1=$(wc -c < "${filearray[0]}")
    fsize2=$(wc -c < "${filearray[1]}")

    echo "The first file is ${fsize1} bytes"
    echo "The next file is $fsize2 bytes"

    if (($fsize1 > $fsize2)); then
    echo "Renaming ${filearray[1]} to black.png, ${filearray[0]} to [email protected]"
    mv "${filearray[1]}" black.png
    mv "${filearray[0]}" [email protected]

    elif (($fsize2 > $fsize1)); then
    echo "Renaming ${filearray[1]} to black.png, ${filearray[0]} to [email protected]"
    mv "${filearray[0]}" black.png
    mv "${filearray[1]}" [email protected]

    else
    echo "Echo echo echo..."
    fi

    cp black.png etched.png
    cp black.png silver.png
    echo "Copied black.png"

    cp [email protected] [email protected]
    cp [email protected] [email protected]
    echo "Copied [email protected]"

    echo "Respringing"
    respring
    So now it looks in the folder, compares two files to see which is bigger, renames them both appropriately then copies and renames the copies as needed.

    Now I'm going to try to figure out a way to make it run through all the folders in the Zeppelin directory and check for folders with only 2 files in them.
    Last edited by citric; 04-01-2013 at 05:42 PM.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •