Bulk create lessons for course

$course_id = 123;    				// Change me to the Course you want to create the lessons under
$lessons_to_create_count = 100;		// The number of lessons to create. 
//------------------------------------------------------

$count = 0;
if (!empty( $course_id ) ) {
	while( $count <= $lessons_to_create_count ) {
		$count += 1;
	
		$lesson_post = array(
			'post_title' 	=>	'Lesson #'. $count,
	        'post_content'  =>  '',
			'post_type'		=>	'sfwd-lessons',
			'post_status'	=>	'publish'
		);

		$lesson_post_id = wp_insert_post( $lesson_post ) ;
		error_log('lesson_post_id['. $lesson_post_id .'] title['. $lesson_post['post_title'] .']');
		if ( $lesson_post_id ) {
			update_post_meta( $lesson_post_id, 'course_id', $course_id );
		}
	}
}