Best way to iterate folders and subfolders

If you’re using .NET 4, you may wish to use the System.IO.DirectoryInfo.EnumerateDirectories and System.IO.DirectoryInfo.EnumerateFiles methods. If you use the Directory.GetFiles method as other posts have recommended, the method call will not return until it has retrieved ALL the entries. This could take a long time if you are using recursion. From the documentation: The EnumerateFilesand … Read more

Iterate through folders, then subfolders and print filenames with path to text file

Charles’ answer is good, but can be improved upon to increase speed and efficiency. Each item produced by os.walk() (See docs) is a tuple of three items. Those items are: The working directory A list of strings naming any sub-directories present in the working directory A list of files present in the working directory Knowing … Read more

PHP – Listing all directories and sub-directories recursively in drop down menu [duplicate]

RecursiveDirectoryIterator should do the trick. Unfortunately, the documentation is not great, so here is an example: $root=”/etc”; $iter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore “Permission denied” ); $paths = array($root); foreach ($iter as $path => $dir) { if ($dir->isDir()) { $paths[] = $path; } } print_r($paths); This generates the following output … Read more

PowerShell FTP download files and subfolders

The .NET framework or PowerShell do not have any explicit support for recursive file operations (including downloads). You have to implement the recursion yourself: List the remote directory Iterate the entries, downloading files and recursing into subdirectories (listing them again, etc.) Tricky part is to identify files from subdirectories. There’s no way to do that … Read more

Travel directory tree with limited recursion depth

I think the easiest and most stable approach would be to copy the functionality of os.walk straight out of the source and insert your own depth-controlling parameter. import os import os.path as path def walk(top, topdown=True, onerror=None, followlinks=False, maxdepth=None): islink, join, isdir = path.islink, path.join, path.isdir try: names = os.listdir(top) except OSError, err: if onerror … Read more

Browse files and subfolders in Python

You can use os.walk() to recursively iterate through a directory and all its subdirectories: for root, dirs, files in os.walk(path): for name in files: if name.endswith((“.html”, “.htm”)): # whatever To build a list of these names, you can use a list comprehension: htmlfiles = [os.path.join(root, name) for root, dirs, files in os.walk(path) for name in … Read more

Using visual basic to access subfolder in Inbox?

Thats very close 🙂 To get all the mail items in a folder called “temp” under the Inbox try this Dim olApp As Outlook.Application Dim objNS As Outlook.NameSpace Dim olFolder As Outlook.MAPIFolder Dim msg As Outlook.MailItem Set olApp = Outlook.Application Set objNS = olApp.GetNamespace(“MAPI”) Set olFolder = objNS.GetDefaultFolder(olFolderInbox) Set olFolder = olFolder.Folders(“Temp”) For Each msg … Read more

How can I deploy Symfony in a subdirectory?

Here I wrote exactly about that: https://www.refactory-project.com/install-symfony-app-in-a-subfolder-of-an-existing-site/ Upload the application part Start by uploading the application folders at the same level of your site root: [ftproot] — public_html —- … —- … — symfonyapp —- app —- bin —- src —- vendor —- web —— app.php —— app_dev.php —— … —- composer.json —- composer.lock Move … Read more