PDA

View Full Version : Handling filenames in python


rui_mac
12-06-2010, 05:53 PM
How can I manipulate filenames in python?
Lets say that I want to add a filename at the end of a path. Or I simply want to print an absolute path.
I have a path that I got with:

pref_folder=c4d.storage.GeGetC4DPath(c4d.C4D_PATH_PREFS)

Now I want to add a filename to the end to save a file in the preferences folder, for example. How do I do that? I tried using os.path.join(pref_folder,"myfile.txt")
But it tells me that the name "os" is not defined.
I searched the documentation for ways to handle filenames but I only found references to the os.path stuff.
Damn, I complained about the COFFEE documentation but sometimes the python documentation is way more complex.

Rui Batista

ernia
12-06-2010, 07:17 PM
Hi Rui,

Did you import the OS module first?

import os

Arik

rui_mac
12-07-2010, 01:41 AM
That was it. Thank you :-)
Now I'm dealing with other problems... but, slowly, things are getting done.

Rui Batista

CGTalk Moderation
12-07-2010, 01:41 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.