preface: as mentioned in @Gez answer, its likely you won't actually want to do some automated conversion from RGB to CMYK, however... there may be some situations where an automated conversion makes sense and can be tweaked to fit your needs -, in that case, this answer may be useful to you.