Batch folder renaming?

This isn’t necessarily Kodi specific, so it may be considered “off-topic”, but it is video/audio library specific. I am a fairly organized person with a touch of “OCD”. I want my folders to all have the same naming convention, which should match the filename of the file contained in said directory. Is there and command-line or program that could do this?