Yes! It is not very difficult. We recommend using imapsync to perform this task. This can be done via a web interface, Windows application, or command line (Linux best documented).
Web interfaces: https://imapsync.lamiral.info/X/
Windows: https://imapsync.lamiral.info/dist/
Command line: https://www.howtoforge.com/how-to-migrate-mailboxes-between-imap-servers-with-imapsync