• Post category:Others
  • Post comments:0 Comments
  • Post last modified:July 14, 2023
  • Reading time:4 mins read
You are currently viewing How to get the list of all files in a folder as well as sub-folders in Windows?

In this article, let’s look into extracting the list of all filenames in a folder and sub folders in windows.

This might not be related to HCM Cloud but has use cases. Below are the use cases where I had to use this functionality.

  • For loading Photos where client provides a folder with all photos of employees.
  • For loading Resumes for candidates where the client provides a zip file of all resumes.
  • For loading Payslips for employees, which might need to be loaded to DOR or Payroll Inbound Interface Records, where the client provides the zip of payslips.
  • For loading Descriptions for Requisitions, where the client provides descriptions in text files.
  • For all the above cases, If we have to prepare the HDL, we have to get the filenames for the files. As the files will be in huge number, doing it manually is not an option as it is prone to errors as well.

    First, place all the files in a folder.

    image 4 - How to get the list of all files in a folder as well as sub-folders in Windows?

    Now, lets open command prompt

    Search for cmd in windows search

    image 5 - How to get the list of all files in a folder as well as sub-folders in Windows?

    Next, use the change directory cd command to navigate to the folder where files are present

    image 6 - How to get the list of all files in a folder as well as sub-folders in Windows?

    next use the below command “dir /b > filenames.txt” without double quotes. This will extract the filenames and put it in a text file in the same folder.

    image 7 - How to get the list of all files in a folder as well as sub-folders in Windows?

    Once we run this command, we can go back and check the folder.

    image 8 - How to get the list of all files in a folder as well as sub-folders in Windows?

    We can see the filenams.txt got created.

    Here is the contents of the file:

    image 9 - How to get the list of all files in a folder as well as sub-folders in Windows?

    We can copy these contents to excel for preparing the HDL file. Will be very useful during data migrations.