I have windows xp and I have a few questions about directories. How do you make directories and how do you set them as your current directory. I need to know how to do this so I can use scripts on python.
5 2050
There is a two library modules called os and ospath with lots of functions to make sure that strings look like valid path names for whatever platform you are on and functions for getting and setting the current working directory. Python 2.4 docs sections 6.1 and 6.2.
I have no idea what you are talking about.
I have no idea what you are talking about.
The Python documentation is something that you MUST be able to put your hands on and is the FIRST place to start learning. If your system was properly installed, there in Start->Programs->Python 2.4->Python Manuals. The first page is an index that starts with a tutorial (start here). Then comes the Global Module Index. Follow this link and scroll down to os and ospath and begin your study.
bvdet 2,851
Expert Mod 2GB
I have no idea what you are talking about.
I wrote some applications that read the current working directory and create a directory if it does not exist. These examples may give you an idea about what Barton was talking about : -
# snip
-
import os
-
from macrolib.FileDefaults import import_data, export_data, job_Defaults_path, data_Defaults_path, check_Defaults_dir
-
# system path for default values files
-
# auto save path
-
default_file_path = data_Defaults_path()
-
# user save path
-
job_default_file_path = os.path.join(job_Defaults_path(), "Beam_BPL_Pourstop")
-
# default values file name
-
def_file = "Beam_BPL_Pourstop_v1_12.txt"
-
script_name = "Beam_BPL_Pourstop_v1.12.py"
-
# default to enable or disable the automatic importing and exporting of dialog dictionary variables
-
# ("Enable", "Disable")
-
enable_default_import_export = "Enable"
-
"""
-
The saving and importing of default files requires that a subdirectory 'Defaults' exists.
-
The 'Defaults' directory for automatic import/export is returned by 'data_Defaults_path()' ('SDS/2 root data/macro/Defaults)
-
The 'Defaults' directory for user import/export is returned by 'job_Defaults_path()'('job directory'/macro/Defaults')
-
"""
-
# check if automatic defaults directory exists
-
if enable_default_import_export == "Enable":
-
if not check_Defaults_dir(default_file_path):
-
Warning("Edit the parametric file and change variable 'enable_default_import_export' value to 'Disable'")
-
-
# check if user defaults directory exists
-
if not check_Defaults_dir(job_default_file_path):
-
job_default_file_path = default_file_path
-
-
# dialog box image file path and names
-
image_path = os.path.join(os.getcwd(), "macro", "Images")
-
image_name = os.path.join(image_path, "Beam_BPL_Pourstop.gif")
-
# snip
- # Create the 'Defaults' directory if it does not exist
-
# Example: 'C:\SDS2_7.0\jobs\607_Great_Wolf\macro' is an existing path
-
# Make directory 'C:\SDS2_7.0\jobs\607_Great_Wolf\macro\Defaults'
-
# Return 1 if directory exists or directory creation is successful
-
-
import os
-
import macrolib.pickle
-
-
def check_Defaults_dir(file_path):
-
from param import Warning, yes_or_no
-
if not os.path.isdir(file_path):
-
if yes_or_no("The directory path does not exist. Do you want to create directory '%s'?" % (file_path)):
-
try:
-
os.makedirs(file_path)
-
return True
-
except OSError, e:
-
Warning("Could not create directory %s: %s" % (file_path, e))
-
return False
-
else:
-
return False
-
return True
-
-
###############################################################################
-
# return the path to the job default values directory
-
# format - 'SDS/2 root data'\jobs\'name of job'\macro\Defaults
-
def job_Defaults_path():
-
from job import JobName
-
return os.path.join(os.getcwd(), "jobs", JobName(), "macro", "Defaults")
-
-
###############################################################################
-
# return the path to the data default values directory
-
# format - 'SDS/2 root data'\macro\Defaults
-
def data_Defaults_path():
-
return os.path.join(os.getcwd(), "macro", "Defaults")
You can set the current working directory with os.chdir( path).
I have no idea what you are talking about.
Are you ask about how to create directories in xp?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tum |
last post by:
Hi folks,
I've been trying to make a decision and it's driving me crazy.
Is a directory a file or is a directory NOT a file but a node?
Should I have
A)
|
by: Billy Jacobs |
last post by:
I have a website which has both secure and non-secure
pages. I want to uses forms authentication. How do I
accomplish this?
Originally I had my web.config file in the root with Forms...
|
by: huzz |
last post by:
I need to write script in c# that will scan directories for files and insert
the files and directory names in the database.. I've have two tables tblDir
and tblDocs.
Example:
-Directory1...
|
by: Heath |
last post by:
I'm dealing with a C# application that monitors changes to the file
system, and need to exclude irrelevent directories, temp directories
for example.
Is there any way to identify such...
|
by: Jeffry van de Vuurst |
last post by:
Hi,
(sorry for the crosspost, I wasn't sure which was the best place to
put this).
I was just thinking about something and wondered if any of you has
some ideas about this.
I'm using the...
|
by: Angelo Cook |
last post by:
how do you prevent the publishing of virtual directories in VS 2005.
I have been using VS2003 and developing websites for years. I have been
using virtual directories for images, icons, styles...
|
by: rn5a |
last post by:
I have a ListBox which should list all the files & directories that
exist in a particular directory. The problem is I can get the ListBox
to list either all the files or all the directories but not...
|
by: rn5a |
last post by:
A ListBox lists all the folders & files existing in a directory named
'MyDir' on the server. Assume that the ListBox lists 2 directories -
'Dir1' & 'Dir2' i.e. these 2 directories reside in the...
|
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= |
last post by:
Hello,
I am using Visual Studio-2003. I created a project to build my library.
Since I am using third party libraries as well, I have specified those
additional library dependencies in project...
|
by: Edwin Velez |
last post by:
http://msdn.microsoft.com/en-us/library/806sc8c5.aspx
The URL above gives sample code for use within a Console Application. What
I would like to do is use this code within a Windows Form. That...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |