subtledoctor Posted May 13, 2020 Share Posted May 13, 2020 My little MacOS mod "manager" sits in the game folder and tries to find all mods; the default method for this is to look for any file with a .tp2 extension. Right now, the app sits in your game folder and drills into all subfolders to find any files that end in ".tp2", because that's how I managed to use the "find" command. But, it finds a lot of garbage - several mods actually include internal .tp2 files that are not themselves mods, instead of giving those files a ".tpa" or ".tph" extension like a civilized person. I would really like to limit the command to finding .tp2 files in the main game folder (some old mods keep them separate from the mod folder) or one level deeper, i.e. in the mod folders themselves, but not in any mod's subfolders. The command currently looks like this: find [game_folder_path] -iname *.tp2 I have no idea whether the find command can be fashioned in such a way without an unpleasant amount of complication. Does anyone here have any idea? Quote Link to comment
argent77 Posted May 13, 2020 Share Posted May 13, 2020 (edited) The find option "-maxdepth 2" can be used to limit search to the game directory and the first level of subfolders in the search path. However, that might still list bogus files if there are multiple .tp2 files present in a mod folder. find game_folder -maxdepth 2 -iname *.tp2 Alternatively you could use regular expressions for the search. However, they are really messy since you'd have to escape so many special characters: find game_folder -regextype sed -iregex "game_folder/\(\(.\+\)/\)\?\(setup-\)\?\2\.tp2" Edited May 13, 2020 by argent77 Quote Link to comment
subtledoctor Posted May 13, 2020 Author Share Posted May 13, 2020 (edited) 11 minutes ago, argent77 said: The find option "-maxdepth 2" can be used to limit search to the game directory and the first level of subfolders in the search path. However, that might still list bogus files if there are multiple .tp2 files present in a mod folder. It woulds get me 90% of the way there (apparently 99%, actually), which in this case is sufficient. EDIT - in a folder with >100 mods, I'm down to a single false positive. Thanks!! Edited May 13, 2020 by subtledoctor Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.