Mostly the folders already exist, however each time the files are generated there is the possibility for additional folders also to be generated. So I need my script to create the folder for each file if it does not already exist.

would create any directory that didn't already exist and then upload the file to it. I don't see why this is not possible?

To recursively scan each directory to discover if a particular location already exists coupled with the requisite string manipulation to create said folders is starting to sound like an awful lot of work for what should surely be a simple, automatic operation.

I currently do use the synchronize function but because the amount of files and folders is so large this takes a very long time (1-2 hours every day) and puts unnecessary load on the server. The file generator outputs a list of modified files each time it runs so I am trying to switch over to just uploading the modified files, rather than having to run synchronize for two hours every day.