Print Directory & File Structure with icons for representation in Markdown [closed]

I followed an example in another repository and wrapped the directory structure within a pair of triple backticks (“`): “` project │ README.md │ file001.txt │ └───folder1 │ │ file011.txt │ │ file012.txt │ │ │ └───subfolder1 │ │ file111.txt │ │ file112.txt │ │ … │ └───folder2 │ file021.txt │ file022.txt “`

How to get only images using scandir in PHP?

You can use glob $images = glob(‘/tmp/*.{jpeg,gif,png}’, GLOB_BRACE); If you need this to be case-insensitive, you could use a DirectoryIterator in combination with a RegexIterator or pass the result of scandir to array_map and use a callback that filters any unwanted extensions. Whether you use strpos, fnmatch or pathinfo to get the extension is up … Read more

Populate TreeView with file system directory structure

Option #1: Recursive approach: private void ListDirectory(TreeView treeView, string path) { treeView.Nodes.Clear(); var rootDirectoryInfo = new DirectoryInfo(path); treeView.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo)); } private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo) { var directoryNode = new TreeNode(directoryInfo.Name); foreach (var directory in directoryInfo.GetDirectories()) directoryNode.Nodes.Add(CreateDirectoryNode(directory)); foreach (var file in directoryInfo.GetFiles()) directoryNode.Nodes.Add(new TreeNode(file.Name)); return directoryNode; } Option #2: Non-recursive approach: private static void ListDirectory(TreeView treeView, … Read more

Listing directory contents using C and Windows

Just like everyone else said (with FindFirstFile, FindNextFile and FindClose)… but with recursion! bool ListDirectoryContents(const char *sDir) { WIN32_FIND_DATA fdFile; HANDLE hFind = NULL; char sPath[2048]; //Specify a file mask. *.* = We want everything! sprintf(sPath, “%s\\*.*”, sDir); if((hFind = FindFirstFile(sPath, &fdFile)) == INVALID_HANDLE_VALUE) { printf(“Path not found: [%s]\n”, sDir); return false; } do { … Read more

List directory tree structure in python?

Here’s a function to do that with formatting: import os def list_files(startpath): for root, dirs, files in os.walk(startpath): level = root.replace(startpath, ”).count(os.sep) indent=” ” * 4 * (level) print(‘{}{}/’.format(indent, os.path.basename(root))) subindent=” ” * 4 * (level + 1) for f in files: print(‘{}{}’.format(subindent, f))

Best practice for Django project working directory structure [closed]

There’re two kind of Django “projects” that I have in my ~/projects/ directory, both have a bit different structure.: Stand-alone websites Pluggable applications Stand-alone website Mostly private projects, but doesn’t have to be. It usually looks like this: ~/projects/project_name/ docs/ # documentation scripts/ manage.py # installed to PATH via setup.py project_name/ # project dir (the … Read more

mkdir -p functionality in Python [duplicate]

For Python ≥ 3.5, use pathlib.Path.mkdir: import pathlib pathlib.Path(“/tmp/path/to/desired/directory”).mkdir(parents=True, exist_ok=True) The exist_ok parameter was added in Python 3.5. For Python ≥ 3.2, os.makedirs has an optional third argument exist_ok that, when True, enables the mkdir -p functionality—unless mode is provided and the existing directory has different permissions than the intended ones; in that case, OSError … Read more