473,385 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

a question on directories

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.
Nov 27 '06 #1
5 2050
bartonc
6,596 Expert 4TB
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.
Nov 27 '06 #2
I have no idea what you are talking about.
Nov 27 '06 #3
bartonc
6,596 Expert 4TB
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.
Nov 27 '06 #4
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:
Expand|Select|Wrap|Line Numbers
  1. # snip
  2.     import os
  3.     from macrolib.FileDefaults import import_data, export_data, job_Defaults_path, data_Defaults_path, check_Defaults_dir
  4.     # system path for default values files
  5.     # auto save path
  6.     default_file_path = data_Defaults_path()
  7.     # user save path
  8.     job_default_file_path = os.path.join(job_Defaults_path(), "Beam_BPL_Pourstop")
  9.     # default values file name
  10.     def_file = "Beam_BPL_Pourstop_v1_12.txt"
  11.     script_name = "Beam_BPL_Pourstop_v1.12.py"
  12.     # default to enable or disable the automatic importing and exporting of dialog dictionary variables
  13.     # ("Enable", "Disable")
  14.     enable_default_import_export = "Enable"
  15.     """
  16.         The saving and importing of default files requires that a subdirectory 'Defaults' exists.
  17.         The 'Defaults' directory for automatic import/export is returned by 'data_Defaults_path()' ('SDS/2 root data/macro/Defaults)
  18.         The 'Defaults' directory for user import/export is returned by 'job_Defaults_path()'('job directory'/macro/Defaults')
  19.     """
  20.     # check if automatic defaults directory exists
  21.     if enable_default_import_export == "Enable":
  22.         if not check_Defaults_dir(default_file_path):
  23.             Warning("Edit the parametric file and change variable 'enable_default_import_export' value to 'Disable'")
  24.  
  25.     # check if user defaults directory exists
  26.     if not check_Defaults_dir(job_default_file_path):
  27.         job_default_file_path = default_file_path
  28.  
  29.     # dialog box image file path and names
  30.     image_path = os.path.join(os.getcwd(), "macro", "Images")
  31.     image_name = os.path.join(image_path, "Beam_BPL_Pourstop.gif")
  32. # snip
Expand|Select|Wrap|Line Numbers
  1. # Create the 'Defaults' directory if it does not exist
  2. # Example: 'C:\SDS2_7.0\jobs\607_Great_Wolf\macro' is an existing path
  3. # Make directory 'C:\SDS2_7.0\jobs\607_Great_Wolf\macro\Defaults'
  4. # Return 1 if directory exists or directory creation is successful
  5.  
  6. import os
  7. import macrolib.pickle
  8.  
  9. def check_Defaults_dir(file_path):
  10.     from param import Warning, yes_or_no
  11.     if not os.path.isdir(file_path):
  12.         if yes_or_no("The directory path does not exist. Do you want to create directory '%s'?" % (file_path)):
  13.             try:
  14.                 os.makedirs(file_path)
  15.                 return True
  16.             except OSError, e:
  17.                 Warning("Could not create directory %s: %s" % (file_path, e))
  18.                 return False
  19.         else:
  20.             return False
  21.     return True
  22.  
  23. ###############################################################################
  24. # return the path to the job default values directory
  25. # format - 'SDS/2 root data'\jobs\'name of job'\macro\Defaults
  26. def job_Defaults_path():
  27.     from job import JobName
  28.     return os.path.join(os.getcwd(), "jobs", JobName(), "macro", "Defaults")
  29.  
  30. ###############################################################################
  31. # return the path to the data default values directory
  32. # format - 'SDS/2 root data'\macro\Defaults
  33. def data_Defaults_path():
  34.     return os.path.join(os.getcwd(), "macro", "Defaults")
You can set the current working directory with os.chdir(path).
Nov 28 '06 #5
bartonc
6,596 Expert 4TB
I have no idea what you are talking about.
Are you ask about how to create directories in xp?
Nov 28 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
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)
6
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...
1
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...
1
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...
2
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...
2
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...
4
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...
1
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...
6
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...
4
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
0
BarryA
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...
0
marktang
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,...
0
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...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.