Python – Listing the files in a directory

Language:
Python 2.7

The following example uses functions from the os library to list the files in a given directory:

from os import listdir
from os.path import isfile, join
dir = "D:\\"
files = [f for f in listdir(dir) if isfile(join(dir, f))]
for f in files:
	print join(dir, f)

In the next example the script has been modified to list only files with the name extension ‘jpg’:

from os import listdir
from os.path import isfile, join
dir = "D:\\"
files = [f for f in listdir(dir) if isfile(join(dir, f)) and f[-3:]=='jpg']
for f in files:
	print join(dir, f)

 

* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.

Advertisements

Windows 10 – Getting the convenient automatic folder navigation tree expansion back.

Software:
Microsoft Windows 10

  1. In the folder toolbar, Click the View tab.
  2. Click the Navigator pane drop-down on the left,
    And enable Expand to open folder.

Untitled-1.jpg

 

Related:
Get a file’s folder path

3ds max Project Folder

Software:
3ds max 2017

Setting up a ‘Project Folder’ for every project we work on in 3ds max can improve workflow efficiency by having the software file opening, saving, and importing operations etc. be directed to a specific defined destination in the hard drive by default,
And by doing that save us the time it takes to locate the same folders in the hard drive again and again.

When using this workflow, we must create a unique folderĀ for every project we work on,
And set the Project Folder in 3ds max to the the relevant folder when switching between projects.

To set up a Project Folder:
File > Manage > Set Project Folder

or press the Project Folder button located at the top left of the 3ds max window:

Untitled-1