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
6002
votes
52 answers

How do I find all files containing specific text on Linux?

I'm trying to find a way to scan my entire Linux system for all files containing a specific string of text. Just to clarify, I'm looking for text within the file, not in the file name. When I was looking up how to do this, I came across this…
Nathan
  • 65,860
  • 11
  • 32
  • 47
5373
votes
71 answers

How can I get the source directory of a Bash script 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
  • 67,024
  • 38
  • 154
  • 182
4737
votes
27 answers

How can I safely create a nested directory?

What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried: import os file_path = "/my/directory/filename.txt" directory =…
Parand
  • 91,328
  • 43
  • 147
  • 182
4623
votes
36 answers

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

How can I add an empty directory (that contains no files) to a Git repository?
Laurie Young
  • 129,506
  • 13
  • 44
  • 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
  • 42,933
  • 11
  • 25
  • 15
2542
votes
13 answers

How to delete a file or folder?

How do I delete a file or folder in Python?
Zygimantas
  • 25,707
  • 5
  • 16
  • 23
2498
votes
13 answers

Find current directory and file's directory

In Python, what commands can I use to find: the current directory (where I was in the terminal when I ran the Python script), and where the file I am executing is?
John Howard
  • 50,339
  • 21
  • 44
  • 63
1973
votes
20 answers

How to change permissions for a folder and its subfolders/files in one step?

I would like to change the permissions of a folder and all its subfolders and files in one step (command) in Linux. I have already tried the below command but it works only for the mentioned folder: chmod 775 /opt/lampp/htdocs Is there a way to set…
Adam Halasz
  • 51,803
  • 63
  • 138
  • 208
1364
votes
39 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
  • 13,661
  • 3
  • 13
  • 5
1263
votes
14 answers

How to find if directory exists in Python

In the os module in Python, is there a way to find if a directory exists, something like: >>> os.direxists(os.path.join(os.getcwd()), 'new_folder')) # in pseudocode True/False
David542
  • 96,524
  • 132
  • 375
  • 637
1066
votes
26 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
  • 43,989
  • 14
  • 80
  • 146
1035
votes
15 answers

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

I want to get the current file's directory path. I tried: >>> os.path.abspath(__file__) 'C:\\python27\\test.py' But how can I retrieve the directory's path? For example: 'C:\\python27\\'
Shubham
  • 16,795
  • 17
  • 56
  • 84
802
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
  • 12,568
  • 15
  • 47
  • 65
772
votes
23 answers

How do I ignore a directory with SVN?

I just started using SVN, and I have a cache directory that I don't need under source control. How can I ignore the whole directory/folder with SVN? I am using Versions and TextMate on OS X and commandline.
Gilean
  • 14,428
  • 10
  • 43
  • 52
769
votes
8 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
  • 21,470
  • 25
  • 65
  • 97
1
2 3
99 100