dirname Questions
4
Okay, so I was following a MERN stack tutorial and the tutor wrote out some lines of code but didn't really explain them well. this is the code:
const path = require("path");
const { file...
14
Solved
If I have a file path such as...
/home/smith/Desktop/Test
/home/smith/Desktop/Test/
How do I change the string so it will be the parent directory?
e.g.
/home/smith/Desktop
/home/smith/Desktop/...
7
Solved
My script:
#!/usr/bin/env bash
PATH=/home/user/example/foo/bar
mkdir -p /tmp/backup$PATH
And now I want to get first folder of "$PATH": /home/
cd /tmp/backup
rm -rf ./home/
cd - > /dev...
9
Suppose I have a file /from/here/to/there.txt, and want to get only the last part of its dirname to instead of /from/here/to, what should I do?
7
Solved
as I already mentioned in the title, I'm looking for a JS-function for getting the same result like I get with this PHP code:
dirname(dirname(__FILE__))
Thanks in advance!
Armet asked 3/11, 2012 at 5:4
5
Solved
I find myself needing to get a parent directory of a python file in a source tree that is multiple directories up with some regularity. Having to call dirname many times is clunky.
I looked around...
5
How do I use the GNU C Library version of basename() and dirname()?.
If you
#include <libgen.h>
for dirname
You're already getting the POSIX, not the GNU, version of basename(). (Even if...
9
Solved
I have a folder structure as follows:
mydomain.example
->Folder-A
->Folder-B
I have a string from Database that is ../Folder-B/image1.jpg, which points to an image in Folder-B.
Inside a sc...
11
Solved
I have a filename (C:\folder\foo.txt) and I need to retrieve the folder name (C:\folder) in C++. In C# I would do something like this:
string folder = new FileInfo("C:\folder\foo.txt").Di...
3
Solved
Many of my colleagues use the following commands in their BEGIN block.
$scriptDir = dirname($0);
chdir($scriptDir);
$scriptDir = getcwd();
I have looked around and can't help but think that the ...
5
Solved
Say I have a symlink from '/one/directory/' to '/two/directory/'.
If I echo dirname(dirname(\__FILE__)), it returns '/one/directory/'.
What is the best method to return '/two/directory'?
Example...
1
Solved
Since I'm using both Windows' cmd.exe and msysgit's bash, trying to access the Windows-path output by os.getcwd() is causing Python to attempt accessing a path starting with a drive letter and a co...
2
Solved
I am using a php library which has this code: require_once dirname(__FILE__) . '/config.php';
From what I've read, dirname(__FILE__) points to the current directory.
So wouldn't it be easier to j...
Doubleton asked 15/1, 2014 at 21:12
2
Solved
Citing the manual here:
The functions dirname() and basename() break a null-terminated
pathname string into directory and filename components. In the usual
case, dirname() returns the string u...
2
Solved
The only solution I've encountered is to use regular expressions and recursively replace the first directory until you get a word with no slashes.
gsub("/\\w*/","/",gsub("/\\w*/","/",getwd()))
I...
5
Solved
I want to create a simple bash script to launch a Java program on OS X. The names of the file, the file path, and the immediate working folder all contain spaces. When I do this:
#!/bin/sh
cd `dir...
1
© 2022 - 2025 — McMap. All rights reserved.