Export All D365 F&O Custom Models with a Single Batch File

 

Export All D365 F&O Custom Models with a Single Batch File

 

In Microsoft Dynamics 365 Finance and Operations (D365 F&O), managing and exporting models can be a repetitive task, especially when you're dealing with a large number of custom models. To streamline this process, you can automate model exports using a simple batch file.

In this blog, I’ll walk you through how to create a .bat file that exports all your custom models in one go—without needing to execute each command manually. This is especially helpful during regular backups or before code deployments.


🧠 Why Use a Batch File?

A batch file allows you to:

  • Export multiple models in one go

  • Create backups with date-based folders automatically

  • Reduce human error and save time

  • Reuse and modify easily


📂 Folder Structure Assumption

In this example, we're assuming the following:

  • D365 metadata is located at K:\AosService\PackagesLocalDirectory

  • ModelUtil.exe is located in K:\AosService\PackagesLocalDirectory\bin

  • You want to store exported models in E:\Backup\ with a folder for each day’s date (e.g.,  E:\Backup\04-09-2025\)


🛠️ Step-by-Step: The Batch Script

Below is the complete content of the batch file saved as ExportModels.bat:

k: cd K:\AosService\PackagesLocalDirectory\bin
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%b-%%c-%%a) if not exist "E:\Backup\%mydate%" ( mkdir E:\Backup\%mydate% ) ModelUtil.exe -export -metadatastorepath=K:\AosService\PackagesLocalDirectory -modelname="Model1" -outputpath=E:\Backup\%mydate% ModelUtil.exe -export -metadatastorepath=K:\AosService\PackagesLocalDirectory -modelname="Model2" -outputpath=E:\Backup\%mydate%
ModelUtil.exe -export -metadatastorepath=K:\AosService\PackagesLocalDirectory -modelname="Model2" -outputpath=E:\Backup\%mydate%

✅ How to Use It

  1. Open Notepad and paste the script above.

  2. Save the file with a .bat extension, for example: ExportModels.bat.

  3. Right-click the file and select Run as Administrator.

All your models will be exported into a date-stamped folder under E:\Scales\, making them easy to track and manage.


🔁 Bonus Tip: Schedule It

You can schedule this batch file to run daily using Task Scheduler, ensuring your models are always backed up without lifting a finger.


📝 Conclusion

This simple batch file can save you hours of manual work and ensure consistent backups of your custom models in Dynamics 365 F&O. It's a practical solution for DevOps workflows, pre-deployment routines, or nightly backups.


Refernce :- Click here

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++

75) COC - Create a coc of the table modified method