Questions tagged [subdirectory]
A subdirectory is a directory that is contained inside another directory.
2,677
questions
2038
votes
31
answers
1.5m
views
How do I clone a subdirectory only of a Git repository?
I have my Git repository which, at the root, has two subdirectories:
/finisht
/static
When this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so:
...
964
votes
35
answers
1.6m
views
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.
612
votes
21
answers
713k
views
Directory-tree listing in Python
How do I get a list of all files (and directories) in a given directory in Python?
398
votes
6
answers
659k
views
How to perform grep operation on all files in a directory?
Working with xenserver, and I want to perform a command on each file that is in a directory, grepping some stuff out of the output of the command and appending it in a file.
I'm clear on the command I ...
236
votes
4
answers
137k
views
How can I create nonexistent subdirectories recursively using Bash?
I am creating a quick backup script that will dump some databases into a nice/neat directory structure and I realized that I need to test to make sure that the directories exist before I create them. ...
182
votes
16
answers
264k
views
PHP Get all subdirectories of a given directory
How can I get all sub-directories of a given directory without files, .(current directory) or ..(parent directory)
and then use each directory in a function?
174
votes
18
answers
349k
views
List all files and directories in a directory + subdirectories
I want to list every file and directory contained in a directory and subdirectories of that directory. If I chose C:\ as the directory, the program would get every name of every file and folder on the ...
149
votes
5
answers
234k
views
Import module from subfolder
I want to import subfolders as modules. Therefore every subfolder contains a __init__.py. My folder structure is like this:
src\
main.py
dirFoo\
__init__.py
foofactory.py
dirFoo1\
...
112
votes
10
answers
215k
views
In Unix, how do you remove everything in the current directory and below it?
I know this will delete everything in a subdirectory and below it:
rm -rf <subdir-name>
But how do you delete everything in the current directory as well as every subdirectory below it and the ...
107
votes
4
answers
148k
views
Correctly ignore all files recursively under a specific folder except for a specific file type
I have seen similar questions (1, 2 and 3), but I don't get a proper solution from them.
I need to ignore all files under a particular folder except for a specific file type. The folder is a ...
101
votes
6
answers
105k
views
How to remove .htaccess password protection from a subdirectory
I have password protected my entire website using .htaccess but I would like to expose one of the sub directories so that it can be viewed without a password.
How can I disable htaccess password ...
87
votes
6
answers
419k
views
How do I get a list of folders and sub folders without the files?
I am trying to print a list of the folders and sub folders of a directory to a file.
When I run dir /s/b/o:n > f.txt, I get a list of the files also. I only need the folders and sub folders.
...
80
votes
1
answer
27k
views
Rails 4: organize rails models in sub path without namespacing models?
Would it be possible to have something like this?
app/models/
app/models/users/user.rb
app/models/users/education.rb
The goal is to organize the /app/models folder better, but without having to ...
75
votes
6
answers
196k
views
Browse files and subfolders in Python
I'd like to browse through the current folder and all its subfolders and get all the files with .htm|.html extensions. I have found out that it is possible to find out whether an object is a dir or ...
71
votes
7
answers
264k
views
Pick images of root folder from sub-folder
Let's say following is the directory structure of my website :
Now in index.html I can simply refer images like:
<img src="./images/logo.png">
But I want to refer the same image from sub.html....
67
votes
2
answers
61k
views
How to use QMake's subdirs template?
I'm starting to learn Qt. I'm moving from the Visual Studio world and I am looking for a way to organize my project's structure using QMake. I've found the 'subdirs' template but I have quite a hard ...
64
votes
10
answers
48k
views
C# Remove all empty subdirectories
I have a task to clean up a large number of directories. I want to start at a directory and delete any sub-directories (no matter how deep) that contain no files (files will never be deleted, only ...
62
votes
9
answers
56k
views
How to install Laravel 4 to a web host subfolder without publicly exposing /app/ folder?
I was wondering if any of you know of a way to install Laravel 4 in a web host SUBDIRECTORY / subfolder while not exposing the /app/ folder and other sensible files to the publicly accessible part of ...
59
votes
3
answers
44k
views
Git Ignore everything in a directory except subfolders
This is my folder structure:
data/
.gitignore
uploads/
.gitignore
I would like to commit the folders but not the files inside them.
So I add a .gitignore files in every folder with ...
50
votes
8
answers
52k
views
Return total number of files in directory and subdirectories
Trying to create a function that returns the # of files found a directory and its subdirectories. Just need help getting started
47
votes
6
answers
108k
views
Best way to iterate folders and subfolders
What's the best way to iterate folders and subfolders to get file size, total number of files, and total size of folder in each folder starting at a specified location?
46
votes
3
answers
40k
views
Git repository within Git repository [duplicate]
I have a main git repository A and we are using sources out of another git repository B in a subdirectory of our main project.
Now it would be good to have the B repository checked out within the A ...
42
votes
1
answer
26k
views
SVN move single directory into other repository (with history)
Related question: Moving repository trunk to another’s branch (with history)
I know that one can dump a complete SVN repository with history and load it into a user-defined (sub)directory of the ...
41
votes
3
answers
114k
views
Iterate through folders, then subfolders and print filenames with path to text file
I am trying to use python to create the files needed to run some other software in batch.
For part of this I need to produce a text file that loads the needed data files into the software.
My problem ...
39
votes
4
answers
14k
views
Can I move the .git directory for a repo to it's parent directory?
I have two sub-directories each with a repo, thus :
PPP/
|--ABC/
| |--.git/
| |--AAA/
| | BBB/
| | CCC/
|
|--DEF/
| |--.git/
| |--DDD/
| |--EEE/
And would like to ...
38
votes
4
answers
58k
views
Android studio Where to install NDK file? (downloaded it in zip)
My android studio said it wanted to update. But when I did I tried to update it but it wouldn't work so I had to launch:
C:\Users\username\AppData\Local\Android\sdk\tools\android.bat to install other ...
37
votes
9
answers
27k
views
Javascript Redirect with Google Analytics
I need help figuring out how to successfully redirect while including Analytics code.
I have a subdomain setup http://buuf.fractalsystems.org
The subdomain is actually just a subfolder http://...
37
votes
4
answers
17k
views
How do I get socket.io running for a subdirectory
I've got a proxy running that only hits my node.js server for paths that being with /mysubdir
How do I get socket.io configured for this situation?
In my client code I tried:
var socket = io.connect(...
36
votes
1
answer
16k
views
Multiple .gitignore in subfolders
Is it possible to have a .gitignore file in a subfolder, so that i may be better able to control what i need to be ignored and not affect a larger, "base" gitignore?
For example, there is the root ....
35
votes
2
answers
24k
views
git-archive a subdirectory --
I'm using git-archive to archive a subdirectory in a git repo, like so:
git archive -o ../subarchive.zip HEAD subdir/*
However the resulting archive maintains the subdir/ directory structure, i.e. ...
33
votes
3
answers
46k
views
Use a subdirectory as root with htaccess in Apache 1.3
I'm trying to deploy a site generated with Jekyll and would like to keep the site in its own subfolder on my server to keep everything more organized.
Essentially, I'd like to use the contents of /...
33
votes
4
answers
20k
views
Package name is different than the folder structure but still Java code compiles
I am using Notepad++ to write my Java code and Command Prompt to compile and run it.
Following is my sample Java code,
package abraKadabra;
public class SuperClass{
protected int ...
32
votes
2
answers
9k
views
Multiple directories and/or subdirectories in IPython Notebook session?
The IPython documentation pages suggest that opening several different sessions of IPython notebook is the only way to interact with saved notebooks in different directories or subdirectories, but ...
31
votes
4
answers
9k
views
Configure git to track only one file extension
I have one directory tree with many kind of different files. There are 300 directories on the parent directory. Each directory could have other sub directories.
I only want to track *.cocci on all ...
30
votes
3
answers
16k
views
how to deploy django under a suburl behind nginx
I have a django application running on http://localhost:12345 .
I'd like user to access it via url http://my.server.com/myapp .
I use nginx to reverse proxy to it like the following:
... ...
...
27
votes
4
answers
53k
views
Recursive make in subdirectories
How can I order make command in the Makefile to execute recursively in all subdirectories make commands (defined in the Makefile in the subdirectories)?
26
votes
3
answers
47k
views
make wildcard subdirectory targets
I have a "lib" directory in my applications main directory, which contains an arbitrary number of subdirectories, each having its own Makefile.
I would like to have a single Makefile in the main ...
25
votes
11
answers
94k
views
How to move all files with specific extension from all subdirectories to their parent using CMD?
Folder c:\folder1 contains subfolder1, subfolder2, etc..
These subdirectories hold .pdf and .db files.
How can all the .pdf files be moved to c:\folder1 using the Windows command interpreter?
25
votes
6
answers
39k
views
Using pytest where test in subfolder
I'm using python pytest to run my unit tests.
My project folders are:
Main - contains data file: A.txt
Main\Tests - the folder from which I run pytest
Main\Tests\A_test - folder that contains a test ...
24
votes
4
answers
12k
views
How to save an image in a subdirectory on android Q whilst remaining backwards compatible
I'm creating a simple image editor app and therefore need to load and save image files. I'd like the saved files to appear in the gallery in a separate album. From Android API 28 to 29, there have ...
23
votes
5
answers
75k
views
Remove all files, folders and their subfolders with php [duplicate]
I need a script which can remove a whole directory with all their subfolders, files and etc. I tried with this function which I found in internet before few months ago but it not work completely.
...
23
votes
3
answers
21k
views
Is there's a command for yarn to install a subfolder?
Background:
We are using yarn in this project and we don't want to write our package.json scripts with a mix of npm/yarn commands.
I have a root directory which contains a few subfolders.
Each holds a ...
22
votes
4
answers
5k
views
How can I use a subdirectory instead of a subdomain?
I'm building a rails app that I'll host on Heroku at domain.com. And I'd like to use WordPress for the blog hosted on phpfog, but I don't want to use a subdomain like blog.domain.com. I'd instead ...
22
votes
4
answers
26k
views
How to control subdirectory compiling order of cmake?
This is my CMakeLists.txt:
ADD_SUBDIRECTORY(third)
ADD_SUBDIRECTORY(utils)
ADD_SUBDIRECTORY(rpc)
But the directory 'rpc' will be compiled before directory 'utils', actually the 'rpc' is depends on '...
22
votes
1
answer
17k
views
When should I use pathlib.Path.mkdir() vs os.mkdir() or os.makedirs()? [duplicate]
According to python 3.6 documentation, a directory can be created via:
pathlib.Path.mkdir(mode=0o777, parents=False, exist_ok=False)
os.mkdir(path, mode=0o777, *, dir_fd=None)
os.makedirs(name, mode=...
21
votes
2
answers
57k
views
grep in all directories
I have a directory named XYZ which has directories ABC, DEF, GHI inside it. I want to search for a pattern 'writeText' in all *.c in all directories (i.e XYZ, XYZ/ABC, XYZ/DEF and XYZ/GHI)
What grep ...
21
votes
2
answers
31k
views
python os.walk to certain level [duplicate]
I want to build a program that uses some basic code to read through a folder and tell me how many files are in the folder.
Here is how I do that currently:
import os
folders = ['Y:\\path1', 'Y:\\...
20
votes
1
answer
86k
views
Moving entire folder and all its contents to another folder [duplicate]
Just need a batch script that will move one folder and all its contents into another folder.
Essentially this
C:\Folder1 to C:\Folder2\Folder 1
20
votes
1
answer
41k
views
CMake subdirectories dependency
I am very new to CMake. In fact, I am trying it through Kdevelop4 widh C++.
I have the habit of creating subdirs for every namespace I create, even if all the sources must be compiled and linked into ...
19
votes
1
answer
5k
views
meteor private subdirectory
I was recently made aware of meteor private subdirectories. According to the docs: "The private subdirectory is the place for any files that should be accessible to server code but not served to the ...