Bulk Rename Files With Less Than 50 Lines of Javascript From an Excel Sheet

Last week a coworker received an excel sheet from a client that looked like this (replaced the actual data with similar data for this example)

and attached were hundreds of images with file names from the “Old Item Code” column in the Excel sheet exhibited above, these file names required renaming to “New Item Code” values before they were ready to be uploaded in bulk in D365 Business Central.

For illustrative purposes, here is the content of the images folder.

To get this done in a programmatic way, below are 50 lines of code that renames image files off of an excel sheet.

after running the script, here is the content of images folder;

Now let us create 4 blank images with “Old Item Code” written on it to differentiate better images from each other and verify if the script renamed the images correctly;

After running the script;

Want to automate a tedious task? Write to me at [email protected] or connect with me on LinkedIn

Leave a Reply