pazaway12 Posted September 13, 2022 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 10 Reputation: 0 Joined: 06/20/20 Last Seen: August 12, 2024 Share 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 Link to comment Share on other sites More sharing options...
0 Tokei Posted September 26, 2022 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 696 Reputation: 721 Joined: 11/12/12 Last Seen: 3 hours ago Share 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 Link to comment Share on other sites More sharing options...
0 pazaway12 Posted September 27, 2022 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 10 Reputation: 0 Joined: 06/20/20 Last Seen: August 12, 2024 Author Share 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 Link to comment Share on other sites More sharing options...
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?
Link to comment
Share on other sites
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.