Questions tagged [chdir]

chdir (or cd) is a command to change the working directory (change directory). It is part of many operating systems and programming languages. On many OS `chdir()` also is a system call.

cd, sometimes also available as chdir (change directory), is a command line command to change the current working directory in operating systems such as Unix, DOS, OS/2, AmigaOS (where if a bare path is given, cd is implied), Windows, and Linux. It is also available for use in shell scripts and batch files.

More details see cd Wikipedia article

182 questions
2
votes
1 answer

How can I change directories in a thread safe way?

I'd like to spawn 2 threads and move each one into a different working directory. std::thread t1([](){ boost::filesystem::current_path("/place/one"); // operate within "place/one" }); std::thread t2([](){ …
Trevor Hickey
  • 31,728
  • 22
  • 131
  • 236
2
votes
1 answer

chdir in perl using two strings: chdir "/home/$dir1/$dir2"

I have two strings: $dir1 and $dir2. I want to use chdir as shown below: chdir "/home/$dir1/$dir2"; when I try this it doesn't change the directory. I checked the current working directory same as before Is there any way to do this?
techie
  • 59
  • 5
2
votes
2 answers

Documentation describing this python windows os.chdir behavior?

I learned today that in python on windows, doing os.chdir('f:\\') is very different than doing os.chdir('f:'). The command with the trailing backslash actually changes the current directory. Without the backslash, the command is like typing f: in…
aggieNick02
  • 2,106
  • 1
  • 19
  • 29
2
votes
1 answer

Strange (internal?) default constructor error message using chdir in Perl 6 REPL

I'm facing the following error: &*chdir('/home/account') Failed to change the working directory to '/home/account': Default constructor for 'IO::Path' only takes named arguments What do I need to change to overcome this error? (I am using…
branco
  • 107
  • 8
2
votes
1 answer

Unexpected print() and os.listdir() functionality

import os target_dir = "xxx.xxx.xx.xx/path/to/file/dir" start_seq = "*** Start Sequence ***" end_seq = "*** End Sequence ***" def tp_parser(file): with open(file) as in_f: lines = in_f.readlines() f_name = in_f.name[12:16] …
blackmore5
  • 73
  • 1
  • 6
2
votes
1 answer

Display and delete files from subfolders based on select value

My folder structure has 4 layers with my form in the top layer, currently it displays the files in the top layer only, I want to be able to select a subfolder and display the files in it so they can be deleted if…
Kilisi
  • 366
  • 8
  • 29
2
votes
1 answer

C Segfault in readdir after chdir

I am having a weird issue with this C program I'm writing to loop through a directory and open each file to do some work on. My program is located in the parent directory of the directory I'm searching through. In order for fopen to be able to see…
2
votes
2 answers

Using chdir() to change directory from Terminal

I am using chdir() to change directory to the value passed as an argument to this function. I understand that when I run my C program using gcc myCd.c and ./a.out .. this changes the directory to the parent directory "within" the C program (i.e. a…
Ashwin Tumma
  • 772
  • 1
  • 13
  • 28
2
votes
4 answers

chdir programmatically

In Windows -- and probably Unix for that matter -- using the chdir() function in a (32-bit) program doesn't change the directory when the program exits. (It does in a 16-bit Windows program.) Does anybody know how to do that in a Windows 32-bit…
james owen
2
votes
2 answers

How to change Current Working directory using AppleScript

What would be a simplest way to change a current working directory (cwd) using AppleScript. It would be equivalent to OS's cd or Python's os.chdir. Would be great if a destination directory if doesn't exist would be created on a fly (but that would…
alphanumeric
  • 13,847
  • 39
  • 164
  • 305
2
votes
3 answers

What's that best way to move through directories?

Are both of the examples below OK, or is the second one bad style? Case 1: Stay in top directory and use catdir to access subdirectories #!/usr/bin/env perl use warnings; use strict; my $dir = 'my_dir_with_subdir'; my ( $count, $dh ); use…
sid_com
  • 21,289
  • 23
  • 89
  • 171
2
votes
1 answer

PHP FTP return to FTP-user Root folder

How can I return to the ftp users root folder. In this example it is /isi/ in my home/user/ dir. $location = $order; $real_location = $workflow_location =$leverancier; if (!@ftp_chdir($ftp_conn, $real_location)) { …
Dyam
  • 33
  • 5
2
votes
1 answer

Ruby: How to get the correct full path of a source file after a chdir?

See the following example: puts __FILE__ #test.rb puts File.expand_path(__FILE__) #C:/TEMP/test.rb Dir.chdir('..') puts __FILE__ #test.rb puts File.expand_path(__FILE__) …
knut
  • 25,655
  • 5
  • 79
  • 107
2
votes
2 answers

Batch script fails with "The system cannot find the path specified"

I have written the following batch script, which runs another batch script on a directory, or, with addition of a flag, on a directory tree and then on an equivalent directory or directory tree on a different drive (Z:). No matter which option I…
ZackG
  • 137
  • 3
  • 3
  • 9
2
votes
2 answers

Change directory of parent process after exit

Possible Duplicate: How do I set the working directory of the parent process? Is possible to make the change of directory persist after program exit? Since it resets to original directory when program exits.
user1243746
1 2
3
12 13