Actually the game keeps track of which "directory" it is in and uses this to find the files, name + directory goes into the LGP parser but the directory is only used if there is a conflict. However, with FF7PC being a fairly shoddy port this system is not used in any sort of consistent way. The battle module has its own encoder/decoder for converting PSX filenames into the cryptic 4-letter sequences from the PC version but I guess they couldn't be bothered with that for the magic effects so they were left as-is. At the same time, some modules use the mangled PC names straight up, completely doing away with the PSX names. In short, it is definitely possible to sort out the magic effects into separate directories but it will probably need a bunch of manual work to sort out the odd file where the directory happens to be incorrect.
Either way, the crucial piece of metadata that ties these files together is hardcoded in the .exe, magic effects (which are hardcoded) explicitly load their own models and textures as they execute.