Questions tagged [directory]

A directory or folder is a 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 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

19503 questions
7328
votes
55 answers

How to find all files containing specific text (string) on Linux?

How do I find all files containing a specific string of text within their file contents? The following doesn't work. It seems to display every single file in the system. find / -type f -exec grep -H 'text-to-find-here' {} \;
Nathan
  • 73,987
  • 14
  • 40
  • 69
6134
votes
75 answers

How do I get the directory where a Bash script is located from within the script itself?

How do I get the path of the directory in which a Bash script is located, inside that script? I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash script is located, so I…
Jiaaro
  • 74,485
  • 42
  • 169
  • 190
5551
votes
27 answers

How do I create a directory, and any missing parent directories?

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
  • 102,950
  • 48
  • 151
  • 186
5251
votes
37 answers

How do I add an empty directory to a Git repository?

How do I add an empty directory (that contains no files) to a Git repository?
Laurie Young
  • 136,234
  • 13
  • 47
  • 54
3467
votes
21 answers

How do I list all files of a directory?

How can I list all files of a directory in Python and add them to a list?
duhhunjonn
  • 44,855
  • 11
  • 28
  • 15
3284
votes
17 answers

How can I delete a file or folder in Python?

How can I delete a file or folder in Python?
Zygimantas
  • 33,165
  • 6
  • 21
  • 23
2934
votes
13 answers

Find the current directory and file's directory

How do I determine: the current directory (where I was in the shell when I ran the Python script), and where the Python file I am executing is?
John Howard
  • 61,037
  • 23
  • 50
  • 66
2178
votes
19 answers

How do I change permissions for a folder and its subfolders/files?

How do I change the permissions of a folder and all its subfolders and files? This only applies to the /opt/lampp/htdocs folder, not its contents: chmod 775 /opt/lampp/htdocs How do I set chmod 755 for all of the /opt/lampp/htdocs folder's current…
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
1875
votes
43 answers

Download a single folder or directory from a GitHub repo

How can I download only a specific folder or directory from a remote Git repo hosted on GitHub? Say the example GitHub repo lives here: git@github.com:foobar/Test.git Its directory structure: Test/ ├── foo/ │ ├── a.py │ └── b.py └── bar/ …
g_inherit
  • 18,771
  • 3
  • 16
  • 5
1534
votes
15 answers

How do I check if a directory exists in Python?

How do I check if a directory exists in Python?
David542
  • 104,438
  • 178
  • 489
  • 842
1415
votes
12 answers

How do I get the full path of the current file's directory?

How do I get the current file's directory path? I tried: >>> os.path.abspath(__file__) 'C:\\python27\\test.py' But I want: 'C:\\python27\\'
Shubham
  • 21,300
  • 18
  • 66
  • 89
1259
votes
29 answers

Listing only directories using ls in Bash?

This command lists directories in the current path: ls -d */ What exactly does the pattern */ do? And how can we give the absolute path in the above command (e.g. ls -d /home/alice/Documents) for listing only directories in that path?
Sibi
  • 47,472
  • 16
  • 95
  • 163
1069
votes
32 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
  • 84,019
  • 84
  • 236
  • 374
991
votes
13 answers

In a Git repository, how to properly rename a directory?

I think it should work to copy the directory to be renamed to a new directory with desired name, and delete the old directory, and git add, git commit and push everything. But is this the best way?
qazwsx
  • 25,536
  • 30
  • 72
  • 106
939
votes
16 answers

If a folder does not exist, create it

I use a FileUploader control in my application. I want to save a file to a specified folder. If this folder does not exist, I want to first create it, and then save my file to this folder. If the folder already exists, then just save the file in…
Tavousi
  • 14,848
  • 18
  • 51
  • 70
1
2 3
99 100