Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,194,916 members, 7,956,439 topics. Date: Monday, 23 September 2024 at 12:00 PM

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

Nairaland Forum / Science/Technology / Programming / Programming Challenge(python,java,vb,.net: Etc) (3795 Views)

Programming Challenge For Beginners Competition Two N20000 -SEASON 2- / Programming Challenge For Beginners N20000 / Facebook Programming Challenge Question (2) (3) (4)

(1) (Reply) (Go Down)

Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 9:37am On Nov 19, 2008
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
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 9:08pm On Nov 23, 2008
Well it seems no body is willing to answer my question cry

undecidedwell 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
Re: Programming Challenge(python,java,vb,.net: Etc) by judy4all: 5:27am On Nov 30, 2008
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,
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 3:41pm On Nov 30, 2008
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
Re: Programming Challenge(python,java,vb,.net: Etc) by Seun(m): 12:55pm On Dec 02, 2008
I admire the way you have used your favorite language to solve your file management problem. Well done.
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 8:50am On Dec 03, 2008
@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
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 12:41am On Dec 31, 2008
Coming soon: filemanager {edited} in JAVA
Re: Programming Challenge(python,java,vb,.net: Etc) by candylips(m): 1:49pm On Dec 31, 2008
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
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 7:16am On Jan 02, 2009
@candylips
thanks.still a beginner working on that.i will edit it very soon.like he use to say PYTHON IS NOT JAVA
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 11:07pm On Jan 02, 2009
@candylips
THANKS FOR YOUR CHALLENGE
HERE IS THE NEW [COLOR=RED]DESKTOP FILE MANAGER[/COLOR]



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> ')

[B] [COLOR=BLUE]TILL LEARNING [/COLOR][/B]
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 10:09am On Jan 10, 2009
How can i write this same code in java
Re: Programming Challenge(python,java,vb,.net: Etc) by Nobody: 8:20pm On Jan 11, 2009
@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." - https://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.
Re: Programming Challenge(python,java,vb,.net: Etc) by netghost: 10:18pm On Jan 30, 2009
have u worked with glade 2
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 1:05pm On Jan 31, 2009
Glade 2 ?.
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 1:08pm On Jan 31, 2009
Glade 2 ?.
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 1:09pm On Jan 31, 2009
Glade 2 ?.
Re: Programming Challenge(python,java,vb,.net: Etc) by netghost: 1:50am On Feb 02, 2009
glade is a program that allows u to create gui the same way u will do it in vb thAT is drag and drop
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 12:25am On Feb 05, 2009
ooook grin.
@netghost
Any contribution ??
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 12:26am On Feb 05, 2009
ooook grin.
@netghost
Any contribution ??
Re: Programming Challenge(python,java,vb,.net: Etc) by nitation(m): 8:00am On Feb 07, 2009
I can actually make this a web based desktop manager using PHP/MYSQL + Ajax(not necessary)
Re: Programming Challenge(python,java,vb,.net: Etc) by jacob05(m): 1:36pm On Feb 07, 2009
@nitation
you are so much welcomed contribute to this code.
Re: Programming Challenge(python,java,vb,.net: Etc) by wEDee: 4:54pm On Feb 07, 2009
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.
Re: Programming Challenge(python,java,vb,.net: Etc) by nitation(m): 1:21pm On Feb 08, 2009
@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

(1) (Reply)

Facebook Database Schema (take A Look *parental Advisory*) / The Best I.T Course To Study.... / Benefits Of Hacking, Reliable Schools Offering It?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 33
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.