Necessity is the Mother of Invention - Batch Job

Hey CEans,

I would like to share something interesting happened just now, when I wanted to do something! ๐Ÿ˜€ This is one solid proof that if you have the will to do, you will find a way somehow! ๐Ÿ˜€

So, what did I do? I was downloading about 25 files for some work of mine and I had to organise them into folders, under my Downloads folder. Each file has a description in a URL and the file itself has a unique name. Lets consider there are three files for now.
File #1
File:      NetBeans IDE
File Name: netbeans-7.1-ml-php-windows.exe
File URL:  https://netbeans.org/downloads/start.html?platform=windows&lang=en&option=php
 
File #2
File:      Eclipse IDE
File Name: eclipse-jee-indigo-SR1-win32.zip
File URL:  https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/indigosr1
 
File #3
File:      Aptana Studio
File Name: Aptana_Studio_3_Setup_3.0.8.exe
File URL:  https://www.aptana.com/products/studio3/download
Now I want them in a folder structure this way:
/NetBeans IDE
--/netbeans-7.1-ml-php-windows.exe
--/Link.txt (Content: https://netbeans.org/downloads/start.html?platform=windows&lang=en&option=php)
/Eclipse IDE
--/eclipse-jee-indigo-SR1-win32.zip
--/Link.txt (Content: https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/indigosr1)
/Aptana Studio
--/Aptana_Studio_3_Setup_3.0.8.exe
--/Link.txt (Content: https://www.aptana.com/products/studio3/download)
Could anyone guess what did I do? Remember, there are 25 files! ๐Ÿ˜€ I did it in about 3 minutes!!! ๐Ÿ˜€

Replies

  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Okay CEans, I just did this. I opened Microsoft Excel and at first, wrote down the URLs and names of the folders. The sheet looked this way:
    +-----------------------------------------------------------------+
    | https://netbeans.org/d...dows&lang=en&option=php | NetBeans IDE  |
    | https://www.eclipse.org/d...developers/indigosr1 | Eclipse IDE   |
    | https://www.aptana.com/products/studio3/download | Aptana Studio |
    +-----------------------------------------------------------------+
    Then I created the directories for the same using this:
    mkdir NetBeans IDE
    mkdir Eclipse IDE
    mkdir Aptana Studio
    After that I browsed through the Internet to find how am I supposed to create a text file with some contents, using command line. I got this piece of info:
    echo Content > filename
    echo Hello World > New.txt
    This I thought of making use and tried to rearrange the Excel sheet this way:
    +-------------------------------------------------------------------------------------------+
    | echo | https://netbeans.org/d...dows&lang=en&option=php | > " | NetBeans IDE  | \Link.txt" |
    | echo | https://www.eclipse.org/d...developers/indigosr1 | > " | Eclipse IDE   | \Link.txt" |
    | echo | https://www.aptana.com/products/studio3/download | > " | Aptana Studio | \Link.txt" |
    +-------------------------------------------------------------------------------------------+
    Yup, I used Excel's good functions like fill, etc., and made this. Then I copied everything to notepad and used Find & Replace and replaced all the Tab characters to spaces and formatted the output. The final batch command was:
    echo https://netbeans.org/d...dows&lang=en&option=php > "NetBeans IDE\Link.txt"
    echo https://www.eclipse.org/d...developers/indigosr1 > "Eclipse IDE\Link.txt"
    echo https://www.aptana.com/products/studio3/download > "Aptana Studio\Link.txt"
    Finally, I copied all the files using the same batch command! ๐Ÿ˜€ It was a pretty awesome experience, isn't it??? ๐Ÿ˜€
  • Kaustubh Katdare
    Kaustubh Katdare
    That's some Crazy Engineering, Praveen ๐Ÿ‘
  • Dancer_Engineer
    Dancer_Engineer
    That's work done awesomely! ๐Ÿ‘
  • KenJackson
    KenJackson
    Yes, that's one of the more novel uses of a spreadsheet that I've seen.

    But I enjoy routinely whipping out scripts to do this sort of thing.
    On Windows I always install Cygwin so I have a bash shell.
    And on my preferred Linux platform, the bash shell is native.

    Here's a script that does approximately that, though I'm not sure of the URLs.

    #!/bin/bash
    DIR=("NetBeans IDE"
        "Eclipse IDE"
        "Aptana Studio"
        )
    FILE=("netbeans-7.1-ml-php-windows.exe"
          "eclipse-jee-indigo-SR1-win32.zip"
          "Aptana_Studio_3_Setup_3.0.8.exe"
        )
    URL=(
    "netbeans.org/downloads/start.html?platform=windows&lang=en&option=php"
    "www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/indigosr1"
    "www.aptana.com/products/studio3/download"
    )
     
    for n in $(seq 0 2); do
        dir="${DIR[$n]}"
        file="${FILE[$n]}"
        url="${URL[$n]}"
     
        cd /tmp                # or ~/Desktop or wherever
        mkdir -p "$dir"
        cd "$dir"
        wget -c "https://$url/$file"
    done
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    KenJackson
    Yes, that's one of the more novel uses of a spreadsheet that I've seen.

    But I enjoy routinely whipping out scripts to do this sort of thing.
    On Windows I always install Cygwin so I have a bash shell.
    And on my preferred Linux platform, the bash shell is native.

    Here's a script that does approximately that, though I'm not sure of the URLs.

    #!/bin/bash
    DIR=("NetBeans IDE"
        "Eclipse IDE"
        "Aptana Studio"
        )
    FILE=("netbeans-7.1-ml-php-windows.exe"
          "eclipse-jee-indigo-SR1-win32.zip"
          "Aptana_Studio_3_Setup_3.0.8.exe"
        )
    URL=(
    "netbeans.org/downloads/start.html?platform=windows&lang=en&option=php"
    "www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/indigosr1"
    "www.aptana.com/products/studio3/download"
    )
     
    for n in $(seq 0 2); do
        dir="${DIR[$n]}"
        file="${FILE[$n]}"
        url="${URL[$n]}"
     
        cd /tmp                # or ~/Desktop or wherever
        mkdir -p "$dir"
        cd "$dir"
        wget -c "https://$url/$file"
    done
    Nice one, I thought of this, but I didn't wanna use programming here! ๐Ÿ˜› I just used a Windows Batch file to keep all things right! ๐Ÿ˜€ Simple isn't it??? ๐Ÿ˜€
  • eternalthinker
    eternalthinker
    Cool !

    And for future uses, we may code a simple loop which takes content and link as inputs in each iteration ๐Ÿ˜€
    (And create necessary files with the input)
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    eternalthinker
    Cool !

    And for future uses, we may code a simple loop which takes content and link as inputs in each iteration ๐Ÿ˜€
    (And create necessary files with the input)
    Still wondering if loops work in Batch... I have been testing it for long!!! ๐Ÿ˜›
  • Ankita Katdare
    Ankita Katdare
    ๐Ÿ˜ฒ whoa! Never thought that could be done. Will try it some time.
    Great sharing CEan praveen. ๐Ÿ‘
  • Sahithi Pallavi
    Sahithi Pallavi
    Simply Awesome! I'll try it out ๐Ÿ˜€
    Praveen, you are really a Crazy Computer Science Engineer ๐Ÿ‘
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Thankz Sada & AKD!!! ๐Ÿ˜
  • Reya
    Reya
    Thanks for sharing it geeky ๐Ÿ˜€
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Reya
    Thanks for sharing it geeky ๐Ÿ˜€
    Will share again if I become mad and do something great! ๐Ÿ˜€

You are reading an archived discussion.

Related Posts

The Kochi Metro Rail Project is the long cherished dream of citizens of Kochi city. The project is planned keeping in view the cultural heritage and commercial significance of the...
The new iOS app will make it easier for you to decode the resistor and capacitor color codes and also perform circuit & Ohm's law related calculations. The app is...
The premier management education institute in India - IIMA has arranged for a 1.5 Hr lecture to IIM-A students enrolled in the 'Contemporary Film Industry' course. Dhanush will talk about...
I am sure you already read this, but quoting it, The Government Of India intends to involve other three IITs (along with IIT Rajasthan) in the Aakash tablet PC project,...