Questions tagged [directory]

A directory or folder is a virtual container within a digital file system, in which groups of computer files and other directories can be kept and organized.

A directory or folder is a virtual container within a digital file system, in which groups of computer files and other directories can be kept and organized.

A typical file system may contain thousands (or even hundreds of thousands) of directories. Files are kept organized by storing related files in the same directory. A directory contained inside another directory is called a subdirectory or child of that directory. Together, the directories form a hierarchy, or tree structure.

Related

17729 questions
766
votes
24 answers

Importing modules from parent folder

I am running Python 2.5. This is my folder tree: ptdraft/ nib.py simulations/ life/ life.py (I also have __init__.py in each folder, omitted here for readability) How do I import the nib module from inside the life module? I am hoping…
Ram Rachum
  • 71,442
  • 73
  • 210
  • 338
729
votes
32 answers

How to read all files in a folder from Java?

How to read all the files in a folder through Java?
M.J.
  • 14,866
  • 25
  • 70
  • 95
727
votes
36 answers

How can I rename a project folder from within Visual Studio?

My current solution for renaming the project folder is: Remove the project from the solution. Rename the folder outside Visual Studio. Re-add the project to the solution. Is there a better way?
andersjanmyr
  • 10,492
  • 5
  • 26
  • 28
695
votes
30 answers

Getting a list of all subdirectories in the current directory

Is there a way to return a list of all the subdirectories in the current directory in Python? I know you can do this with files, but I need to get the list of directories instead.
Brad Zeis
  • 7,666
  • 5
  • 20
  • 20
694
votes
20 answers

Create a folder if it doesn't already exist

I've run into a few cases with WordPress installs with Bluehost where I've encountered errors with my WordPress theme because the uploads folder wp-content/uploads was not present. Apparently the Bluehost cPanel WordPress installer does not create…
Scott B
  • 35,095
  • 61
  • 148
  • 245
687
votes
9 answers

How can I iterate over files in a given directory?

I need to iterate through all .asm files inside a given directory and do some actions on them. How can this be done in a efficient way?
Itzik984
  • 13,250
  • 24
  • 66
  • 100
658
votes
29 answers

How can I get the list of files in a directory using C or C++?

How can I determine the list of files in a directory from inside my C or C++ code? I'm not allowed to execute the ls command and parse the results from within my program.
samoz
  • 51,592
  • 52
  • 138
  • 190
595
votes
16 answers

How do I find files that do not contain a given string pattern?

How do I find out the files in the current directory which do not contain the word foo (using grep)?
Senthil Kumar
  • 8,157
  • 7
  • 33
  • 44
586
votes
20 answers

Directory-tree listing in Python

How do I get a list of all files (and directories) in a given directory in Python?
Matt
  • 72,111
  • 25
  • 51
  • 64
565
votes
12 answers

How can I find script's directory?

Consider the following Python code: import os print os.getcwd() I use os.getcwd() to get the script file's directory location. When I run the script from the command line it gives me the correct path whereas when I run it from a script run by code…
Jonathan
  • 84,911
  • 94
  • 244
  • 345
564
votes
9 answers

What is the current directory in a batch file?

I want to create a few batch files to automate a program. My question is when I create the batch file, what is the current directory? Is it the directory where the file is located or is it the same directory that appears in the command prompt, or…
Aaron de Windt
  • 13,661
  • 12
  • 44
  • 58
561
votes
13 answers

How do I get the directory from a file's full path?

What is the simplest way to get the directory that a file is in? I'm using this to set a working directory. string filename = @"C:\MyDirectory\MyFile.bat"; In this example, I should get "C:\MyDirectory".
Even Mien
  • 39,111
  • 41
  • 111
  • 117
561
votes
23 answers

Copy the entire contents of a directory in C#

I want to copy the entire contents of a directory from one location to another in C#. There doesn't appear to be a way to do this using System.IO classes without lots of recursion. There is a method in VB that we can use if we add a reference to…
Keith
  • 133,927
  • 68
  • 273
  • 391
527
votes
12 answers

How to git ignore subfolders / subdirectories?

I have a lot of projects in my .Net solution. I would like to exclude all "bin/Debug" and "bin/Release" folders (and their contents), but still include the "bin" folder itself and any dll's contained therein. .gitignore with "bin/" ignores "Debug"…
Marcel
  • 6,051
  • 5
  • 19
  • 25
506
votes
30 answers

How to remove illegal characters from path and filenames?

I need a robust and simple way to remove illegal path and file characters from a simple string. I've used the below code but it doesn't seem to do anything, what am I missing? using System; using System.IO; namespace ConsoleApplication1 { class…
Gary Willoughby
  • 46,098
  • 37
  • 127
  • 193