Skip to main content
Filter by
Sorted by
Tagged with
5803 votes
28 answers
4.0m views

How do I create a directory at a given path, and also create any missing parent directories along that path? For example, the Bash command mkdir -p /path/to/nested/directory does this.
Parand's user avatar
  • 107k
1388 votes
23 answers
2.5m views

Which Python library can I use to extract filenames from paths, no matter what the operating system or path format could be? For example, I'd like all of these paths to return me c: a/b/c/ a/b/c \a\...
BuZz's user avatar
  • 17.6k
1112 votes
24 answers
2.2m views

On Linux, how can I add a directory to the $PATH so it remains persistent across different sessions? Background I'm trying to add a directory to my path so it will always be in my Linux path. I've ...
Ali's user avatar
  • 268k
1078 votes
12 answers
1.6m views

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
  • 52.2k
1051 votes
28 answers
1.1m views

I would like to list all files recursively in a directory. I currently have a directory structure like this: src/main.c src/dir/file1.c src/another-dir/file2.c src/another-dir/nested/files/file3.c I'...
Ben Gartner's user avatar
950 votes
33 answers
929k views

What is the proper way to modify environment variables like PATH in OS X? I've looked on Google a little bit and found three different files to edit: /etc/paths ~/.profile ~/.tcshrc I don't even ...
Paul Wicks's user avatar
  • 66.2k
851 votes
14 answers
684k views

I'm writing a Bash script. I need the current working directory to always be the directory that the script is located in. The default behavior is that the current working directory in the script is ...
jameshfisher's user avatar
  • 37.4k
771 votes
23 answers
2.6m views

I am trying to add C:\xampp\php to my system PATH environment variable in Windows. I have already added it using the Environment Variables dialog box. But when I type into my console: path it doesn't ...
Netorica's user avatar
  • 19.5k
696 votes
46 answers
388k views

I have a data structure like this : var someObject = { 'part1' : { 'name': 'Part 1', 'size': '20', 'qty' : '50' }, 'part2' : { 'name': 'Part 2', '...
Komaruloh's user avatar
  • 7,081
659 votes
33 answers
645k views

My code runs inside a JAR file, say foo.jar, and I need to know, in the code, in which folder the running foo.jar is. So, if foo.jar is in C:\FOO\, I want to get that path no matter what my current ...
Thiago Chaves's user avatar
608 votes
9 answers
448k views

I can't seem to get any search results that explain how to do this. All I want to do is be able to know if a given path is a file or a directory (folder).
ThomasReggi's user avatar
  • 60.4k
537 votes
11 answers
450k views

I often find myself writing R scripts that generate a lot of output. I find it cleaner to put this output into its own directory(s). What I've written below will check for the existence of a directory ...
Chase's user avatar
  • 69.4k
509 votes
11 answers
479k views

I have come up against this problem a few times at inopportune moments: Trying to work on open source Java projects with deep paths Storing deep Fitnesse wiki trees in source control An error trying ...
Jeffrey Cameron's user avatar
496 votes
11 answers
464k views

C# 2008 SP1 I am using the code below: dt.ReadXml("%AppData%\\DateLinks.xml"); However, I am getting an exception that points to the location of where my application is running from: Could not ...
ant2009's user avatar
  • 22.7k
482 votes
26 answers
1.7m views

I want to find out my Python installation path on Windows. For example: C:\Python25 How can I find where Python is installed?
Fang-Pen Lin's user avatar
  • 14.6k
475 votes
4 answers
526k views

Can anyone explain the difference between Server.MapPath("."), Server.MapPath("~"), Server.MapPath(@"\") and Server.MapPath("/")?
Manu's user avatar
  • 29.2k
446 votes
21 answers
1.0m views

I'm building a simple helper script for work that will copy a couple of template files in our code base to the current directory. I don't, however, have the absolute path to the directory where the ...
baudtack's user avatar
  • 30.7k
415 votes
10 answers
394k views

In python, suppose I have a path like this: /folderA/folderB/folderC/folderD/ How can I get just the folderD part?
pepero's user avatar
  • 7,553
390 votes
25 answers
221k views

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
  • 50.9k
377 votes
1 answer
1.3m views

I'm SSH'd into a computer, so I can't use a GUI to access the path name. Is there a way that you can see the path directly on terminal without having to use Nautilus?
vdogsandman's user avatar
  • 5,457
360 votes
13 answers
796k views

I want to create a program that converts files. I would like the user to be able to place the executable file in any directory, and when executing that program (double-clicking on the .exe) I want the ...
user2214609's user avatar
  • 4,991
323 votes
23 answers
259k views

Given two absolute paths, e.g. /var/data/stuff/xyz.dat /var/data How can one create a relative path that uses the second path as its base? In the example above, the result should be: ./stuff/xyz.dat
VoidPointer's user avatar
  • 17.9k
315 votes
13 answers
182k views

I'm having Xcode issues when I try to use Homebrew and Git: xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist, use xcode-select --switch path/...
devB78's user avatar
  • 12.3k
310 votes
12 answers
692k views

String variable contains a file name, C:\Hello\AnotherFolder\The File Name.PDF. How do I only get the file name The File Name.PDF as a String? I planned to split the string, but that is not the ...
Sharon Watinsan's user avatar
308 votes
5 answers
807k views

Suppose I need to refer to the path C:\meshes\as. If I try writing that directly, like "C:\meshes\as", I encounter problems - either some exception, or the path just doesn't work. Is this ...
Gareth's user avatar
  • 3,882

1
2 3 4 5
456