Automatically Generate File IDs from Filenames in Google Sheets

Description
This Apps Script function allows you to automatically generate file IDs for filenames listed in a Google Sheet. By using this script, you can easily retrieve the unique identifiers (IDs) of files stored in Google Drive and update your spreadsheet with these IDs. This is especially useful for managing large inventories of files where each file needs to be uniquely identified.
Instructions

Create a Google Sheet named fileIdFromFileName. Populate the sheet with the following columns: Column A: ID (optional, can be left blank or used for unique identifiers), Column B: Filename (list the filenames of the files you want to retrieve IDs for), Column C: File ID (this column will be populated by the script).

Add the Script by opening your Google Sheet, going to Extensions > Apps Script, deleting any code in the script editor, and replacing it with the script provided below.

Run the Script by clicking on the play button (▶️) in the Apps Script editor. The script will search for the files in your Google Drive and populate Column C with the corresponding file IDs. If a file is not found, the script will set the cell to "File Not Found."