473,397 Members | 2,084 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,397 software developers and data experts.

Getting a filename path from the path+filename

440 256MB
Hi,

I would like to get the path of the given file name.

Say

I/P:

C:\Sample\Sample1.txt

O/P:

Path should be

C:\Sample

-PSB
Apr 26 '07 #1
1 3278
dshimer
136 Expert 100+
This along with lots of really cool stuff in the os.path module see docs
Expand|Select|Wrap|Line Numbers
  1. >>> import os
  2. >>> os.path.dirname('C:\Sample\Sample1.txt')
  3. 'C:\\Sample'
  4.  
Apr 27 '07 #2

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

Similar topics

3
by: noah | last post by:
Is there a way to figure out what filename an email object points to in a qmail style Maildir directory? Hmmm... I don't think so, but I'm hoping I wrong. I instantiated a Maildir mailbox and...
6
by: Steve Lefevre | last post by:
Hey folks - Working with vba in Access 2k, I'm making a form to automatically import a spreadsheet. Everything works great when I hardcode the name of the spreadsheet file; however, I want the...
3
by: Robert Hanson | last post by:
Hi All, I am using the following: Response.WriteFile(strCompleteFileNameAndPath); Where the strCompleteFileNameAndPath contains something like "C:\\SimpleTest\\Bobtest.doc" and the...
7
by: Hitesh | last post by:
Hi, I have a small script here that goes to inside dir and sorts the file by create date. I can return the create date but I don't know how to find the name of that file... I need file that is...
7
by: pedagani | last post by:
Dear comp.lang.c++, I'm trying to read a file with very long filename using ifstream. Although, the file exists the file open for read fails. Is there a restriction on the size? I'm using winXP...
1
by: Freedolen | last post by:
Hi All, With the below code i am able to get the contents, but i need to get the filename whether it is 'index.html' or 'index.htm' or 'google.html'. How can i get it? use strict; use...
18
by: Aaron Gray | last post by:
Has anyone got a code snippet to separate out the path components, ie drive, path, filename, and extension ? Many thanks in advance, Aaron
6
by: SpreadTooThin | last post by:
After I select a file with the OpenFileDialog, I get the file name with .FileName, but I want to know the drive and path where that file is. What function, method, class can I use in C# to get the...
18
by: RedLars | last post by:
Hi, How can check using .NET 1.1 that a string contains a valid filename for winxp? The application in question has a textbox where user can enter filename and only the filename. It should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.