0

First post here.

Is it possible to create a single batch file that can remove the contents of a directory and then add new files to it from another directory? folder structure example

I am using Microsoft flight Simulator which requires community addons to be stored in the "Community" folder. The problem is with lots of aircraft addons and other addons that are utilised alongside each individual aircraft, the "Community" folder inevitably ends up clogged and this can effect the performance of the sim. It also makes diagnosing performance issues relative to particular addons a bit more difficult.

My solution recently has been to create a series of "Community" folders appended with the aircraft name (Community_747, Community_310R and Community_CJ4 etc) and clear the community folder and then add the contents of the appended folders to the community folder based on the aircraft I am going to be flying.

It would be preferable if I could make use of a multi command batch file to carry out that process. I could then add that bat file to a streamdeck profile and give it an aircraft icon for the aircraft so that it would then be possible to one click on the streamdeck for the aircraft I'd like to use. That would keep the community folder minimal and enable for better performance in the flight sim as well as making it easier to diagnose potential addon problems affecting performance.

I hope I have made that as clear as I possibly can and thank you in advance to anyone that could possibly help me move forward with this. It would be very much appreciated.

1 Answer 1

1

There are many ways to do this but for me the easiest would be to use robocopy which can effectively synchronise two directories and has options to remove items from the destination that do not appear in the source.

The effective command would be

robocopy C:\MSFS\Community_747 C:\MSFS\Community /mir

The /mir command combines two other options /e and /purge which do the following

/e Copies subdirectories. This option automatically includes empty directories.

/purge Deletes destination files and directories that no longer exist in the source. Using this option with the /e option and a destination directory, allows the destination directory security settings to not be overwritten.

You can then easily set up a bunch of batch files which simply run robocopy with the relevant source directory changed and should "clean" the main directory up as it goes.

4
  • You beat me to it. I was just writing essentially the same answer. I'm not familiar with streamdeck, but if that allows giveng parameters to the batch file you only need 1 bat-file: Just replace the aircraft name with %1 (e.g) c:\msfs\community_%1) and when calling the bat-file give the name of the aircraft as first parameter.
    – Tonny
    Commented Aug 29, 2022 at 11:54
  • @Tonny true, that would be a potential single batch file solution, but if the streamdeck can run simple commands then robocopy is a simple modifiable one-liner that doesn't really need much more. Putting them in a batch file is slightly redundant but potentially more easily editable using text editors over whatever streamdeck might use.
    – Mokubai
    Commented Aug 29, 2022 at 12:35
  • @Mokubai That worked very well. I've not tested in with streamdeck yet but, I used batch files to create switchable power profile and attached icons to them and they worked fine so I am hoping this works just as easily. I wonder, would it be possible for me to wrap all this into some sort of self installer file to share with the flightsim community. It would be useful to others if I could add every plane in the game and have each aircraft have their own exe that linked to the bat and enabled them to efficiently switch planes and associated addons to a clean community folder. Thanks again. Commented Aug 29, 2022 at 13:08
  • @Tonny That sounds highly efficient but, I wouldn't really know how to go about it. I didn't even know what robocopy was until Mokubai mentioned it :) Commented Aug 29, 2022 at 13:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .