pazaway12 Posted September 13, 2022 Posted September 13, 2022 It can be done manually one by one, can someone help me with a script to do it for all the act files inside a folder? Quote
0 Tokei Posted September 26, 2022 Posted September 26, 2022 Heya, The original script can be opened with Scripts > Open scripts folder > script5_remove_unused_sprites.cs. In your case, you'd want something like this: foreach (var actPath in Directory.GetFiles(@"C:\Test\", "*.act")) { var sprPath = actPath.ReplaceExtension(".spr"); if (!File.Exists(sprPath)) continue; var actFile = new Act(actPath, sprPath); for (int i = actFile.Sprite.Images.Count - 1; i >= 0; i--) { if (actFile.FindUsageOf(i).Count == 0) { actFile.Sprite.Remove(i, actFile, EditOption.AdjustIndexes); } } actFile.SaveWithSprite(actPath, sprPath); } 1 Quote
0 pazaway12 Posted September 27, 2022 Author Posted September 27, 2022 12 hours ago, Tokei said: Heya, The original script can be opened with Scripts > Open scripts folder > script5_remove_unused_sprites.cs. In your case, you'd want something like this: foreach (var actPath in Directory.GetFiles(@"C:\Test\", "*.act")) { var sprPath = actPath.ReplaceExtension(".spr"); if (!File.Exists(sprPath)) continue; var actFile = new Act(actPath, sprPath); for (int i = actFile.Sprite.Images.Count - 1; i >= 0; i--) { if (actFile.FindUsageOf(i).Count == 0) { actFile.Sprite.Remove(i, actFile, EditOption.AdjustIndexes); } } actFile.SaveWithSprite(actPath, sprPath); } Thanks a lot! This did the job right! Quote
Question
pazaway12
It can be done manually one by one,
can someone help me with a script to do it for all the act files inside a folder?
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.