Questions tagged [absolute-path]

global address for a file, independent from the working directory of the calling process

absolute-path
Filter by
Sorted by
Tagged with
1045 votes
11 answers
1.5m views

How to get an absolute file path in Python

Given a path such as "mydir/myfile.txt", how do I find the file's absolute path in Python? E.g. on Windows, I might end up with: "C:/example/cwd/mydir/myfile.txt"
izb's user avatar
  • 50.9k
444 votes
32 answers
462k views

Get filename and path from URI from mediastore

I have an onActivityResult returning from an mediastore image selection which I can get a URI for an image using the following: Uri selectedImage = data.getData(); Converting this to a string gives ...
stealthcopter's user avatar
424 votes
29 answers
1.2m views

How can I generate a list of files with their absolute path in Linux?

I am writing a shell script that takes file paths as input. For this reason, I need to generate recursive file listings with full paths. For example, the file bar has the path: /home/ken/foo/bar ...
Ken's user avatar
  • 77.9k
369 votes
25 answers
199k views

Convert absolute path into relative path given a current directory using Bash

Example: absolute="/foo/bar" current="/foo/baz/foo" # Magic relative="../../bar" How do I create the magic (hopefully not too complicated code...)?
Paul Tarjan's user avatar
  • 49.8k
297 votes
8 answers
293k views

ASP.NET MVC - Find Absolute Path to the App_Data folder from Controller

What is the correct way to find the absolute path to the App_Data folder from a Controller in an ASP.NET MVC project? I'd like to be able to temporarily work with an .xml file and I don't want to ...
BuddyJoe's user avatar
  • 70.5k
184 votes
14 answers
290k views

Resolve absolute path from relative path and/or file name

Is there a way in a Windows batch script to return an absolute path from a value containing a filename and/or relative path? Given: "..\" "..\somefile.txt" I need the absolute path relative to the ...
Nathan Taylor's user avatar
184 votes
22 answers
142k views

Absolute paths (baseUrl) gives error: Cannot find module

I am setting a configuration to run my tests in a create-react-app + typescript app (from which I have ejected). I am using jest + enzyme. In my tsconfig.json I have set baseUrl='./src' so I can use ...
TheSoul's user avatar
  • 5,146
122 votes
5 answers
97k views

What's a "canonical path"?

So, an absolute path is a way to get to a certain file or location describing the full route to it, the full path, and it's OS dependent (the absolute paths for Windows and Linux, for example, are ...
Metafaniel's user avatar
116 votes
8 answers
178k views

Relative path to absolute path in C#?

I have xml files that contain href file paths to images (e.g. "....\images\image.jpg"). The hrefs contain relative paths. Now, I need to extract the hrefs to the images and turn them into absolute ...
Anders's user avatar
  • 12.7k
113 votes
3 answers
128k views

NodeJS - convert relative path to absolute

In my File-system my working directory is here: C:\temp\a\b\c\d and under b\bb there's file: tmp.txt C:\temp\a\b\bb\tmp.txt If I want to go to this file from my working directory, I'll use this ...
cheziHoyzer's user avatar
  • 4,901
109 votes
11 answers
196k views

Get absolute paths of all files in a directory

How do I get the absolute paths of all the files in a directory that could have many sub-folders in Python? I know os.walk() recursively gives me a list of directories and files, but that doesn't ...
madCode's user avatar
  • 3,843
106 votes
6 answers
77k views

How to eliminate absolute path in zip archive if absolute paths for files are provided?

I have two files in two different directories, one is '/home/test/first/first.pdf', the other is '/home/text/second/second.pdf'. I use following code to compress them: import zipfile, StringIO buffer =...
Shang Wang's user avatar
  • 25.3k
104 votes
11 answers
72k views

Expand a possible relative path in bash

As arguments to my script there are some file paths. Those can, of course, be relative (or contain ~). But for the functions I've written I need paths that are absolute, but do not have their ...
laar's user avatar
  • 1,041
101 votes
9 answers
66k views

How to avoid using relative path imports (/../../../redux/action/action1) in create-react-app

I've been using create-react-app package for creating a react website. I was using relative paths throughout my app for importing components, resources, redux etc. eg, import action from '../../../...
Prem's user avatar
  • 1,447
100 votes
3 answers
212k views

How to use relative/absolute paths in css URLs?

I have a production and development server. The problem is the directory structure. Development: http://dev.com/subdir/images/image.jpg http://dev.com/subdir/resources/css/style.css Production: ...
johnlemon's user avatar
  • 21.2k
88 votes
13 answers
151k views

How to get the file-path of the currently executing javascript code

I'm trying to do something like a C #include "filename.c", or PHP include(dirname(__FILE__)."filename.php") but in javascript. I know I can do this if I can get the URL a js file was loaded from (e.g. ...
B T's user avatar
  • 59.4k
85 votes
6 answers
85k views

how to find the target file's full(absolute path) of the symbolic link or soft link in python

when i give ls -l /etc/fonts/conf.d/70-yes-bitmaps.conf lrwxrwxrwx <snip> /etc/fonts/conf.d/70-yes-bitmaps.conf -> ../conf.avail/70-yes-bitmaps.conf so for a symbolic link or soft link, ...
duhhunjonn's user avatar
  • 45.2k
71 votes
5 answers
87k views

constructing absolute path with os.path.join()

I'd like to construct an absolute path in python, while at the same time staying fairly oblivious of things like path-separator. edit0: for instance there is a directory on the root of my filesystem /...
umläute's user avatar
  • 30.1k
64 votes
7 answers
56k views

Converting relative path into absolute path?

I'm not sure if these paths are duplicates. Given the relative path, how do I determine absolute path using a shell script? Example: relative path: /x/y/../../a/b/z/../c/d absolute path: /a/b/c/d
josh's user avatar
  • 14k
62 votes
5 answers
41k views

How can I get MSBUILD to evaluate and print the full path when given a relative path?

How can I get MSBuild to evaluate and print in a <Message /> task an absolute path given a relative path? Property Group <Source_Dir>..\..\..\Public\Server\</Source_Dir> <...
Eric Schoonover's user avatar
62 votes
5 answers
160k views

Do I need to pass the full path of a file in another directory to open()?

I have a folder with ten files in it which I want to loop through. When I print out the name of the file my code works fine: import os indir = '/home/des/test' for root, dirs, filenames in os.walk(...
balcoder's user avatar
  • 719
59 votes
5 answers
52k views

Symlink broken right after creation

I downloaded the linux Tor Browser package, which is a self-contained folder. I made a symlink to the run script: $ ln -s torbrowser/start-tor-browser ~/bin/torbrowser However, the link was broken ...
joshlf's user avatar
  • 22.7k
55 votes
3 answers
50k views

Slash (/) vs tilde slash (~/) in style sheet path

ASP.NET offers two ways to specify paths for style sheets: <link href="/common/black_theme/css/style.css" rel="stylesheet"> (this is working) <link href="~/common/black_theme/css/style.css"...
Kyasa Madhavi's user avatar
52 votes
8 answers
199k views

Relative instead of Absolute paths in Excel VBA

I have written an Excel VBA macro which imports data from a HTML file (stored locally) before performing calculations on the data. At the moment the HTML file is referred to with an absolute path: ...
Gene's user avatar
  • 645
50 votes
3 answers
65k views

How to force an HTML link to be absolute?

In my website, users can put an URL in their profile. This URL can be http://www.google.com or www.google.com or google.com. If I just insert in my PHP code <a href="$url">$url</a>, the ...
Arnaud's user avatar
  • 5,014
49 votes
5 answers
59k views

Asp.Net Absolute Path of a URL

To make it simpler for a webapp to share files with another app on a different server, I'm using a base href tag in my master page. As many people have discovered, this breaks webform paths. I have ...
Brian's user avatar
  • 25.7k
48 votes
8 answers
260k views

PHP absolute path to root

I can't believe PHP doesn't have an easy solution for this simple matter. ASP.NET has a ~ sign that takes care of this issue and starts everything from the root level. Here's my problem: localhost/...
SZT's user avatar
  • 1,886
41 votes
9 answers
77k views

Nodejs absolute paths in windows with forward slash

Can I have absolute paths with forward slashes in windows in nodejs? I am using something like this : global.__base = __dirname + '/'; var Article = require(__base + 'app/models/article'); But on ...
Megh Parikh's user avatar
40 votes
4 answers
89k views

Get path of Android resource

My question is: is it possible to get the absolute path of a resource (in a subdirectory of the res/ folder) in Android? Most of the answers I see to this question on google suggest getting a file ...
Prime's user avatar
  • 4,163
39 votes
5 answers
199k views

src absolute path problem

I have an image in C:\wamp\www\site\img and i try to display it in a page with this: <img src="C:\wamp\www\site\img\mypicture.jpg"/> but it's not working.The file is actually there and if I ...
luca's user avatar
  • 36.9k
38 votes
7 answers
83k views

Get relative path of the page url using javascript

In javascript, how can I get the relative path of the current url? for example http://www.example.com/test/this?page=2 I want just the /test/this?page=2
raklos's user avatar
  • 28.3k
37 votes
6 answers
27k views

What is my script src URL?

Is there a simple and reliable way to determine the URL of the currently-executing JavaScript file (inside a web page)? My only thought on this is to scan the DOM for all the script src attributes to ...
Neil C. Obremski's user avatar
37 votes
1 answer
48k views

Get absolute file path of FileField of a model instance in Django

I have a page where people can upload files to my server. I want to do something with the file in Celery. So, I need to know the absolute filepath of the uploaded FileFiled of my Model. Let's say I ...
Kotlinboy's user avatar
  • 3,825
31 votes
6 answers
34k views

PHP: Require path does not work for cron job?

I have a cron job that needs to include this file: require '../includes/common.php'; however, when it is run via the cron job (and not my local testing), the relative path does not work. the cron ...
gsquare567's user avatar
  • 2,907
31 votes
4 answers
73k views

Django: Get ImageField url in view

I am trying to get ImageField absolute path in Django view so I can open the image, write on it something and then serve it to user. I have problem getting absolute path for the image which is saved ...
Byteme's user avatar
  • 599
30 votes
3 answers
19k views

HTML force URL hyperlink to be treated as non-relative (absolute)

I have a list of URLs that our users have entered for websites of various clients... I am loading this list from the server into a grid for the users to see... I made the URLs clickable by wrapping ...
Ayyoudy's user avatar
  • 3,701
30 votes
7 answers
10k views

Wrong extraction of .attr("href") in IE7 vs all other browsers?

Can it really be true that the attr("href") command for a link is handled very different in IE7 in comparison to all other browsers? Let's say I have a page at http://example.com/page.html and I have ...
EmKay's user avatar
  • 1,089
29 votes
3 answers
38k views

How to find the working folder of a servlet based application in order to load resources

I write a Java servlet that I want to install on many instances of Tomcat on different servers. The servlet uses some static files that are packed with the war file under WEB-INF. This is the ...
Erel Segal-Halevi's user avatar
28 votes
6 answers
38k views

Moving Pages folder in Next.js application to src folder

In a create-next-app Next.js application, I want to move the pages folder in the root directory to a src folder. I added a jsconfig.json with the code (below), however now I get the error message &...
nmy1095's user avatar
  • 343
28 votes
7 answers
72k views

How to get the absolute path for a given relative path programmatically in Linux?

How to get the absolute path for a given relative path programmatically in Linux? Incase of Windows we have the _fullpath() API. In other words, I mean what is analogous API to _fullpath of Windows ...
Jay's user avatar
  • 24.6k
27 votes
1 answer
185k views

Server Document Root Path in PHP [closed]

I have a php code line like below $files = glob('myFolder/*'); I want to use absolute path to myFolder in above by using server document root, like below $_SERVER["DOCUMENT_ROOT"]."/myFolder/" It ...
WebStylePress's user avatar
27 votes
4 answers
37k views

How get file path from std::ifstream in c++

I open a file using std::ifstream. I may open file using relative path (file.txt) or absolute path (C:\test\file.txt). As I am passing a string as the file name, I dont know whether it is relative ...
Nilesh Shinge's user avatar
26 votes
5 answers
26k views

Linking using relative path on Github README.md

I am trying to create links in my README.md that link to example code using a relative path, as opposed to the absolute path I am using now. For example, in the markdown file, if I use this: [...
Houdini's user avatar
  • 3,502
26 votes
2 answers
21k views

How to concatenate an absolute path and relative path with QDir?

I have a relative path and absolute path that look something like this: Absolute: /tmp/somedir Relative: anotherdir/file.txt I would like to concatenate the two (/tmp/somedir/anotherdir/file.txt) ...
Nathan Osman's user avatar
  • 72.3k
23 votes
3 answers
60k views

PHP include absolute path

I have a variable on my site called $basePath which is set as: $basePath = '/Systems/dgw/'; I am using it on all my css, js and images tags as so (shortened for better visibility): <link href="&...
digicom's user avatar
  • 556
22 votes
1 answer
8k views

ts-node 'MODULE_NOT_FOUND' when using absolute imports in TypeScript

I stumbled upon a problem with absolute imports. The repository is publicly available here: https://github.com/repetitioestmaterstudiorum/ts-boiler When I'm trying to import a file with absolute path (...
codingforworlddomination's user avatar
20 votes
2 answers
88k views

How to get Java File absolute path from InputStream?

I'm on Java 6 and I have a method that scans the runtime classpath for a file called config.xml. If found, I would like to read the contents of the file into a string: InputStream istream = this....
user avatar
20 votes
1 answer
11k views

Absolute (full) URLs without "http:" in HTML href

I have been seeing this a lot lately and I am unable to find any information on it. Is there a name for it? Which browsers support this?
Xen's user avatar
  • 442
20 votes
2 answers
41k views

Confusion about URI path to configure SQLite database

Hi I am building a web application using Flask and Sqlite3. I had issues with connecting the database for a while and it did not work when I wrote this: #version 1 app.config['SQLALCHEMY_DATABASE_URI'...
bubble rain's user avatar
19 votes
4 answers
12k views

How to get absolute path of file or directory, that does *not* exist?

How can I determine the absolute path of a file or directory from a given relative path in C/C++ on GNU/Linux? I know about realpath(), but it does not work on non-existing files. Let's say the user ...
Fabian Henze's user avatar

1
2 3 4 5
17