Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

In this tutorial, you will learn how to list files, folders, and subfolders using Windows CMD commands and PowerShell.

I’ll also demonstrate using the NTFS Permissions Tool, which is a graphical program that displays the permissions on folders and subfolders.

In this article

Check it out.

List Files and folders using the DIR Command

The dir command is built into all versions of Windows. It is an easy to use command to list files, folders, and subfolders from the Windows command prompt.

Let’s look at some examples.

Example 1. List files and folders in the current directory

To list the files and folders in the current directory, open the Windows command prompt, enter dir and press enter. The dir command by default does not display subfolders.

dir

In this example, my current location is c:\it, so when I run the dir command it will list everything in this folder.

cmd list folders

I have put the command output into colored boxes to explain what each column means.

  • Red = This column is the last modified date of the file or folder
  • Green = Indicates if the item is a folder, folders are labeled with DIR
  • Purple = The size of the file
  • Yellow = Name of the file or folder.

Example 2. List subfolders

Use the /s option to include subfolders.

dir /s

I ran the command from the c:\it location and it lists all subfolders and files from this directory. I’ve highlighted some of the subfolders in the screenshot below.

cmd list folder and subfolders

Example 3. Specify a directory path

To list files and folders from a specific directory enter the complete directory path.

dir /s c:\it

For example, if my current location is the root of c: and I type dir /s c:\it the command will display the items from the c:\it directory.

:/>  Расшифровка клавиатуры на ноутбуке — функциональные клавиши и их значение
Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

Example 4. Export list of files and folders

To export the screen output use the command below. You can name the file whatever you want, in this example, I named the file files2.txt

dir > files2.txt

The file will be saved to the current directory.

Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

Pretty easy right?

I covered some of the most basic dir command options. To see a full list of options type dir /? and press enter.

Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

Display Folder Structure using TREE Command

The tree command is another built-in Windows command. This command will display the contents of a directory in a tree structure. This can be useful to give you an overview of the folder layout.

You must specify a path or this command will start at the root of c

Example 1. List all folders and subfolders using TREE

To list all folders and subfolders enter the tree command and the path.

tree c:\it\toolkit
Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

Example 2. List all folders and files using TREE

To include files with the tree command use the /f option.

tree c:\it\toolkit /f
Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

In my experience, I never use the tree command. I find it more useful when a command provides more details like modified dates, permissions, ownership, and so on. If you just need to see the files and folders with no other details then this is a great option.

Powershell List Folders and Subfolders

You can use the Get-Childitem PowerShell cmdlet to list files and folders. The Get-Childitem cmdlet is similar to dir but much more Powerful.

Let’s look at some examples

Example 1. List files and folders using Get-Childitem

This example gets the folder contents from a specific directory

Get-ChildItem -path c:\it\toolkit
powershell get list of folders

By default, the Get-ChildItem cmdlet lists the mode, LastWriteTime, Length, and Name of the filer or folder.

  • l = Link
  • d – directory
  • a = archive
  • r = read-only
  • h = hidden
  • s = system
:/>  Какие действия выполняет утилита msconfig в windows 10 и 11 на компьютере dell

Example 2. Get subfolders using Get-ChildItem

Use the -Recurse option to get subfolders and files.

Get-ChildItem -path c:\it\toolkit -Recurse
powershell list files and folders

Example 3. Get items using the Depth parameter

You can use the -Depth parameter to control how many subfolders deep to include in the list.

Get-ChildItem -Path C:\it -Depth 2

Example 4. PowerShell List only specific file types

In this example, I will list only files that end in a .msi file extension. This will search all subfolders in the directory path.

get-childitem -path c:\it -include *.msi -recurse
Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

Example 5. PowerShell List only folder or files name

The -Name parameter will only return the file or folder name.

Get-ChildItem -path c:\it\toolkit -Name
Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

Example 6. PowerShell List all Files and Folder Details

To display all details of a file or folder use the fl option.

Get-ChildItem -path c:\it\toolkit | FL

You can see below this command will display additional details, if there are any.

Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

Example 7. PowerShell count files and folders

To get a count of the files and folders use the measure-object option.

Get-ChildItem -path c:\it\toolkit | Measure-Object
powershell count folders

Example 8. Powershell Get Folder Size

You can also use the measure-object option to get the folder size.

Get-ChildItem -path c:\it\toolkit | Measure-Object -Property Length -sum
powershell get folder size

As you can see using PowerShell there are a lot of options when it comes to getting files and folders, you can create some really powerful reports.

Get Folder and Subfolder NTFS Permissions

If you need a report of folders and subfolders that includes who has permission to what, then check out the NTFS Permissions Reporting Tool below.

:/>  Служба windows input experience потребляет много оперативной памяти

Example 1. List NTFS Permissions on Shared Folder

Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы
  • DirectoryName = Path of the folder
  • Account = Account listed on the folder (this can be a user or group)
  • DirectoryOwner = Owner listed on the folder
  • DirectoryRights = Permissions the user or group has to the folder
  • Type = Allow or Deny
  • AppliesTo = What the permissions applies to
  • IsInherited = Are the permissions inherited from a parent folder

Example 2. List Folder Permissions on Local Folder

If you want to check the permissions on a local folder click the browse button or enter the folder path.

Проверьте, что пользовательская лицензия microsoft 365 назначена непосредственно или наследована от группы

Which Command Will You Use?

In this article, I showed you three different commands to get files, folders, and subfolders.

Which command did you find most useful? Let me know in the comments below.

Related Articles