Questions tagged [absolute-path]

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

An absolute (or full) path is the general form of the name of a file or directory that specifies a unique location in a file system. An absolute path contains the root directory and all other subfolders in which the requested file or folder is contained.

833 questions
1017
votes
11 answers

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
  • 50,101
  • 39
  • 117
  • 168
443
votes
32 answers

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 this: content://media/external/images/media/47 Or…
stealthcopter
  • 13,964
  • 13
  • 65
  • 83
409
votes
28 answers

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 but, as far as I can see, both ls and find only give…
Ken
  • 77,016
  • 30
  • 84
  • 101
353
votes
25 answers

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
  • 48,968
  • 59
  • 172
  • 213
296
votes
8 answers

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 hardcode the path. This does not work: …
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
183
votes
14 answers

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 batch file. Example: "somefile.txt" is located in…
Nathan Taylor
  • 24,423
  • 19
  • 99
  • 156
168
votes
21 answers

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 absolute paths when I import modules. For example…
TheSoul
  • 4,906
  • 13
  • 44
  • 74
118
votes
5 answers

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 different). A relative path, on the other hand, is a…
Metafaniel
  • 29,318
  • 8
  • 40
  • 67
112
votes
4 answers

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 path: "../../bb/tmp.txt" In case the file is not exist…
cheziHoyzer
  • 4,803
  • 12
  • 54
  • 81
105
votes
11 answers

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 symlinks resolved. Is there any function for this?
laar
  • 1,051
  • 2
  • 7
  • 3
105
votes
8 answers

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 paths in the file system. I know about the…
Anders
  • 12,556
  • 24
  • 104
  • 151
103
votes
6 answers

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 = StringIO.StringIO() first_path =…
Shang Wang
  • 24,909
  • 20
  • 73
  • 94
101
votes
9 answers

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 '../../../redux/action I have tried using module-alis npm…
Prem
  • 1,447
  • 2
  • 10
  • 21
100
votes
11 answers

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 seem to get me what I want.
madCode
  • 3,733
  • 5
  • 26
  • 31
99
votes
3 answers

How to use relative/absolute paths in css URLs?

I have a production and development server. The problem is the directory structure. Development:…
johnlemon
  • 20,761
  • 42
  • 119
  • 178
1
2 3
55 56