subroutine
noun [ C ]
IT uk/ˈsʌbruːˌtiːn/ usin a large computer program, a set of instructions for a particular small task that is available for repeated use:
In the time it takes you to import one page and adjust the pictures, you could write a subroutine that does it automatically.