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...
Scapolite asked 4/1, 2023 at 10:37

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/...
Geometric asked 8/12, 2011 at 4:12

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...
Bashaw asked 8/7, 2014 at 12:27

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?
Overt asked 18/4, 2014 at 21:3

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...
Shiest asked 12/9, 2014 at 19:1

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...
Medication asked 27/4, 2011 at 9:51

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...
Morava asked 19/6, 2012 at 5:18

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...
Mahican asked 18/6, 2010 at 17:2

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 ...
Generation asked 23/12, 2016 at 6:37

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...
Orndorff asked 25/9, 2012 at 9:44

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...
Bordie asked 18/5, 2016 at 8:2

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...
Melissamelisse asked 10/12, 2012 at 16:32

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...
Rech asked 26/4, 2011 at 21:55

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...
Kiss asked 20/8, 2009 at 21:8
1

© 2022 - 2025 — McMap. All rights reserved.