Programming Challenge(python,java,vb,.net: Etc)

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 22, 2009, 06:27 PM
430887 members and 297974 Topics
Latest Member: chlemz
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Programming Challenge(python,java,vb,.net: Etc)
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Programming Challenge(python,java,vb,.net: Etc)  (Read 1240 views)
jacob05 (m)
Programming Challenge(python,java,vb,.net: Etc)
« on: November 19, 2008, 09:37 AM »

Hi nairalanders, am jacob a beginner in python programming language. I want this thread to be a of source competition or challenge in which a user post a question
(which he or she can and have solve) and wait for answers from other posters and after the question is answered he reveal the source code and if the question again
is not answered in TWO WEEKS he reveal the answer.

NOTE: The question can be solved with any programming language sofar as the answer is correct and multiple answers are also allowed.   

                                       
First challenge: Create a file manager that searches a given system location for .mp3,.pdf,.zip,.doc,.txt,.html,.java,.py,.php,.jar files and extract the files from the given
location  and create folders to save each seperate file format in location of your choice.FINISH:-)                                             

simple???  Well like i have said earlier i am a beginner and i am not to ask hard questions that i can't solve. And forever me of how this post is written because
i am using my phone(free browse). 

SO GOOD LUCK TO YOU ALL 
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #1 on: November 23, 2008, 09:08 PM »

Well it seems no body is willing to answer my question Cry

 :-\well i reveal my source code in PYTHON PROGRAMMING LANGUAGE

but this file manager suchs for '.txt','.py','.doc','.java','.pdf','.htm' and suchs the Desktop

i created this Desktop manager as a result of a problem of having too much files on my desktop
since all my internet downloads are downloaded on desktop and i made it a challenge for myself
not to manually move all the desktop files since they are many and different file format so that bring
about these my desktop manager.





import os
import shutil
print '*******WELCOME TO THESE POWERFUL Desktop Manager*******'
print
folder='D:\Documents and Settings\OYEBANJI\Desktop'
os.chdir(folder)

cwd=os.getcwd()
print '******* Current Direntory is '+cwd+' ********'

for treedir in ('DesktopHTM_FILES','DesktopPAGES','DesktopTEXT','DesktopPYTHON','DesktopJAVA','DesktopPDF','DesktopDOC'):
    if treedir in os.listdir(cwd):
        print '*****PATH '+ treedir + ' Already Exist****'
        print
    if treedir not in os.listdir(cwd):
        print '**** Creating '+ treedir+' Direntory*****'
        os.mkdir(treedir)
        print "***** PATH CREATED ******"

files=[]
for i in ('.txt','.py','.doc','.java','.pdf','.htm'):
    for filename in os.listdir(folder):
       
        if filename.find(i)>-1:

            files+=[folder + "\\" + filename]
           
if len(files) > 0:
    for filename in files:
        if os.path.splitext(filename)[1].upper()[1:]== 'HTM' or 'HTML':
           
            j = os.path.split(filename)[1]
       
            if j in os.listdir('DesktopHTM_FILES'):
           
                print j +' Already in '+ 'DesktopHTM_FILES'
           
                print
           
            if j not in os.listdir('DesktopHTM_FILES'):
           
                q = shutil.move(filename,'DesktopHTM_FILES')

                print "*** MOVED " + filename + " TO " + 'DesktopHTM_FILES'
               
        if os.path.splitext(filename)[1].upper()[1:]== 'TXT':
           
            j = os.path.split(filename)[1]
       
            if j in os.listdir('DesktopTEXT'):
           
                print j +' Already in '+ 'DesktopTEXT'
           
                print
           
            if j not in os.listdir('DesktopTEXT'):
           
                q = shutil.move(filename,'DesktopTEXT')

                print "*** MOVED " + filename + " TO " + 'DesktopTEXT'
        if os.path.splitext(filename)[1].upper()[1:]== 'PY':
           
            j = os.path.split(filename)[1]
       
            if j in os.listdir('DesktopPYTHON'):
           
                print j +' Already in '+ 'DesktopPYTHON'
           
                print
           
            if j not in os.listdir('DesktopPYTHON'):
           
                q = shutil.move(filename,'DesktopPYTHON')

                print "*** MOVED " + filename + " TO " + 'DesktopPYTHON'
        if os.path.splitext(filename)[1].upper()[1:]== 'JAVA':
           
            j = os.path.split(filename)[1]
       
            if j in os.listdir('DesktopJAVA'):
           
                print j +' Already in '+ 'DesktopJAVA'
           
                print
           
            if j not in os.listdir('DesktopJAVA'):
           
                q = shutil.move(filename,'DesktopJAVA')

                print "*** MOVED " + filename + " TO " + 'DesktopJAVA'
        if os.path.splitext(filename)[1].upper()[1:]== 'PDF':
           
            j = os.path.split(filename)[1]
       
            if j in os.listdir('DesktopPDF'):
           
                print j +' Already in '+ 'DesktopPDF'
           
                print
           
            if j not in os.listdir('DesktopPDF'):
           
                q = shutil.move(filename,'DesktopPDF')

                print "*** MOVED " + filename + " TO " + 'DesktopPDF'
        if os.path.splitext(filename)[1].upper()[1:]== 'DOC':
           
            j = os.path.split(filename)[1]
       
            if j in os.listdir('DesktopDOC'):
           
                print j +' Already in '+ 'DesktopDOC'
           
                print
           
            if j not in os.listdir('DesktopDOC'):
           
                q = shutil.move(filename,'DesktopDOC')

                print "*** MOVED " + filename + " TO " + 'DesktopDOC'
    raw_input('ENTER ANY KEY TO EXIT> ')

               
if len(files) < 1:
        print 'No File FOUND'
        raw_input('ENTER ANY KEY TO EXIT> ')

       
           
            #print filename
   

   

judy4all
Re: Programming Challenge(python,java,vb,.net: Etc)
« #2 on: November 30, 2008, 05:27 AM »

This program will be about 20 lines if u write it in shell scripting or in perl,  C will do a better job @ it even,
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #3 on: November 30, 2008, 03:41 PM »

I just want this script to be readable for beginners that is why i did so much of repeatation and i will be glad if you can provide the C or perl version of the script.   Cool
Seun (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #4 on: December 02, 2008, 12:55 PM »

I admire the way you have used your favorite language to solve your file management problem.  Well done.
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #5 on: December 03, 2008, 08:50 AM »

@Mr Seun


thanks very much you don't know happy i am to recieve the admin's commendation although i have been a bad boy lately for posting


free zain's mms ip's   But with this comment i think i will face my programming and stop posting more ip's once again thanks for your comment Cheesy
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #6 on: December 31, 2008, 12:41 AM »

Coming soon: filemanager {edited} in JAVA
candylips (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #7 on: December 31, 2008, 01:49 PM »

that is a lot of code for a very simple task .dont you have utility libraries in python that can help with some of those I/O stuff
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #8 on: January 02, 2009, 07:16 AM »

@candylips
thanks.still a beginner working on that.i will edit it very soon.like he use to  say PYTHON IS NOT JAVA
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #9 on: January 02, 2009, 11:07 PM »

@candylips
THANKS FOR YOUR CHALLENGE
HERE IS THE NEW DESKTOP FILE MANAGER



import os
import shutil
LOCE=(('DesktopWEB',('HTML','HTM','PHP')),('DesktopTEXT',('TXT','RTF')),
              ('DesktopCODES',('PY','JAVA','CLASS','PYC')),
              ('DesktopBOOKS',('PDF','DOC','CHM')))
formats=('.txt','.py','.doc','.java','.pdf','.htm','.html','.php','.class','.chm','.pyc','.rtf')
print '*******WELCOME TO THESE POWERFUL Desktop Manager*******'
print
folder='C:\Users\Oyebanji\Desktop' #LOCATION
os.chdir(folder)
cwd=os.getcwd()
print '******* Current Direntory is '+cwd+' ********'
for treedir in ('DesktopWEB','DesktopTEXT','DesktopCODES','DesktopBOOKS'):
    if treedir in os.listdir(cwd):
        pass
    if treedir not in os.listdir(cwd):
        print '**** Creating '+ treedir+' Direntory*****'
        os.mkdir(treedir)
        print "***** PATH CREATED ******"
files=[]
for i in formats:
    for filename in os.listdir(folder):
        if filename.find(i)>-1:
            files+=[folder + "\\" + filename]         
if len(files) > 0:
    for filename in files:
        for j in LOCE:
            if os.path.splitext(filename)[1].upper()[1:] in j[1]:
                location= os.path.split(filename)[1]
                if location in os.listdir(j[0]):
                    print location +' Already in '+j[0]
                if location not in os.listdir(j[0]):
                    q = shutil.move(filename,j[0])
                    print "*** MOVED " + filename + " TO " + j[0]
    raw_input('ENTER ANY KEY TO EXIT> ')               
elif len(files) < 1:
    print 'No File FOUND'
   
    raw_input('ENTER ANY KEY TO EXIT> ')

TILL LEARNING
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #10 on: January 10, 2009, 10:09 AM »

How can i write this same code in java Huh
*dhtml
Re: Programming Challenge(python,java,vb,.net: Etc)
« #11 on: January 11, 2009, 08:20 PM »

@Jacob - ehm, somehow i dont really see ppl posting so much like that - i love posting codes all over the place - but somehow i dont really feel challenged - i personally see it as chest-thumping - i am the best, i am beta than u, that is wat d word challenge means to me.
I created a thread "Looking For Any Script/Service? Please Check Here." - http://www.nairaland.com/nigeria/topic-214688.0.html in the webmasters section - that one is clear and unequivocal - if this were to be something like that - ppl will surely post problems and others may post solution.
I cant just b going thru my code library and start posting,

Anyway, i will still think of wat to post on your thread later on. Just that - it seems i do more of web development these days.
netghost
Re: Programming Challenge(python,java,vb,.net: Etc)
« #12 on: January 30, 2009, 10:18 PM »

have u worked with glade 2
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #13 on: January 31, 2009, 01:05 PM »

Glade 2 Huh ?.
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #14 on: January 31, 2009, 01:08 PM »

Glade 2 Huh ?.
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #15 on: January 31, 2009, 01:09 PM »

Glade 2 Huh ?.
netghost
Re: Programming Challenge(python,java,vb,.net: Etc)
« #16 on: February 02, 2009, 01:50 AM »

glade  is a program that allows u to create gui the same way u will do it in vb thAT is drag and drop
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #17 on: February 05, 2009, 12:25 AM »

ooook Grin.
@netghost
Any contribution ??
jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #18 on: February 05, 2009, 12:26 AM »

ooook Grin.
@netghost
Any contribution ??
nitation (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #19 on: February 07, 2009, 08:00 AM »

I can actually make this a web based desktop manager using PHP/MYSQL + Ajax(not necessary)


jacob05 (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #20 on: February 07, 2009, 01:36 PM »

@nitation
you are so much welcomed contribute to this code.
wEDee
pdf files on python programming
« #21 on: February 07, 2009, 04:54 PM »

HI
  I have a .pdf file that has all about python programming.
       You can send me an e-mail or call me on this 0803-7388-257 or wedeville@yahoo.com
                     Thank you.
nitation (m)
Re: Programming Challenge(python,java,vb,.net: Etc)
« #22 on: February 08, 2009, 01:21 PM »

@wedee

I would suggest you upload it to a free file upload repository online for newbie's into PYTHON PROGRAMMING

http://www.rapidshare.com/
http://www.megaupload.com/

My 2 cent
 MySQL 5.0 Database Has Been Released!  Please Post All Your Java Programing Questions Here.  Mysql Lower Case Table Names  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.