Extracting a list of file names into a table

by Michał Mioduchowski

Inclusion of a dedicated field with a list of file names in our dataset may in some cases help to maintain organization and traceability of the workflow, enable user to easily locate and reference specific files within a large dataset, or assist in tracking changes or updates over time.

Here You can find a very brief guide on how to extract a full list with a single short command string in a File Explorer (Windows):

  1. Open File Explorer.
  2. Go the folder containing all the files of interest.
  3. Select the directory bar at the top of the file explorer. The text containing specific folder directory should highlight in blue.
  4. Delete the existing text and replace it with following command:
    cmd /c dir /b > "%temp%\Dir.txt" & notepad "%temp%\Dir.txt"
  1. Press "Enter"
    This will open Terminal (which You can promptly close) & a notebook with a listed out file names along with their file extensions.

This list can be copied into an Excel file and then be uploaded to Tableau or PowerBI for further data preperation.

Below You can find a full breakdown of what does the command line used above exactly stand for:

cmd: This is the command to open the Windows command prompt.

/c: This carries out the commands that follow and then terminates.

dir: This is a command used to list the contents of a directory.

/b: This is a parameter for the dir command, which specifies to output only the bare format (file name) without any additional information (such as file size, date, and time).

>: This is a redirection operator that directs the output of the dir command to a file.

"%temp%\Dir.txt": This specifies the file path where the output of the dir command will be saved. %temp% is a system environment variable that points to the temporary directory. In this case, it's being used to store the output file in the temporary directory with the name "Dir.txt" (You can see that in the title of the notebook page that opens upon the execution of command).

&: This is a command separator that allows executing multiple commands in a single line.

notepad: This is a command to open the Notepad text editor.

"%temp%\Dir.txt": This specifies the file path of the text file created earlier. It opens this file in Notepad for viewing.

Putting it all together, this command first lists the file names in the current directory in a bare format (without additional information), saves the list to a text file named "Dir.txt" in the temporary directory, and then opens this text file using Notepad for viewing.