Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-18-2006, 12:59 PM   #1
Registered: Apr 2006
Posts: 81

Rep: Reputation: 15
Python Script Issue*

I am writing a script in Python. It is supposed to go in a bunch of folders in a folder. In each folder is a picture and an XML file. It will then copy the picture file to a new folder, and rename it according to some information in the XML file. Here is what I have so far:

print "Beginning"
top = "~/Comics/Dilbert"
for dirs in os.walk(top, topdown=False):
print "Starting walk"
for files in dirs:
print "Getting files"
currentXML = open(glob.glob('*.plist'),"r")
print "Got XML"
currentPicture = open(glob.glob('*.gif'), "r")
copyfile(currentPicture, "~/Comics2")
print "copied Picture"

It should be copying the image (the XML parsing isn't there yet), but all it does is print "Beginning". What have I done incorrectly? If it is relevant, and I did not think it was for something this simple, I am using Mac OS X 10.4.6.

Edit: Posting this did not keep my indentation, but I believe it is correct.

Last edited by Millenniumman; 06-18-2006 at 01:01 PM.
Old 06-18-2006, 10:21 PM   #2
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu
Posts: 207

Rep: Reputation: 37
glob.glob looks in the current directory by default, and you aren't chdiring to the folders.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
python cgi script and premature end of script headers Neruocomp Programming 1 07-28-2005 12:43 PM
how do I do this in Python? (simple sh script) johnMG Programming 6 12-22-2004 11:05 PM
can anyone help me pl with this eror i a python script safrout Programming 0 08-03-2004 03:38 AM
Python issue coolman0stress Programming 7 05-11-2004 02:35 PM
python script LinuxLala Programming 14 04-07-2004 07:19 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:54 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration