Basically, it would be a Loop(s) in a script. However, there is no way to do it until you decide how you're going to number and label the racks that the wine goes into.
The first thing is this: Each bottle gets an auto-entered non-changeable incrementing serial ID, generated by FileMaker, via the auto-enter options. This is NOT its "location" or anything else. It is NEVER changed. Nor is any other data added to it. It is what is used internally to identify that particular bottle, now and forever.
Now, the racks, that's a different story. The "location" of the bottle is based on the way you number/label the racks. It is a separate field from the above ID field. I really don't know how you'd label the racks. It could be like a giant spreadsheet, with Rack# (if separate), then Columns and Rows. Or just columns and rows. If the the "rack height" is 26 or less, you could use that for the Rows (opposite of a spreadsheet), allowing unlimited columns; or just go with the usual A1, A2,...AA1, AA2, etc..
Considering that you would be putting a batch of new bottles into unbroken open spaces at the end, you'd need a loop that would fill down or across, until it reached the edge, then started again on the next column or row. So it would be a "loop within a loop". Not too hard, unless the racks are separate and different widths/heights (in which case you'd need a Racks table with that data; may want it anyway).
Basically the number/labelling of the location depends upon the physical layout of the racks. It would be changeable; but a bit of a PITA to do a lot of that later.
Thank you Fenton. I probably did not explain it properly or I do not understand your reply. I have sorted the locations in the cellar out. Let's say there are 2,000 unique locations which I can put in a table or a value list. 48 bottles of Chateau X are bought. The wine is in the database already. So in principle I could enter bottle by bottle and add a (free) location for each bottle. However, I would like to enter 48 bottles as one purchase and then link bottle by bottle to a location. Once a location is taken, it should not be available for another wine until it is free again after the bottle has been sold/consumed.