Store a function or even a variable to call in console for Skyrim

Is there a way to create and store a function in skyrim for future use? I don't like having to re-enter codes all the time of what I commonly use, so I'd rather I be able to just call a function like function items() and it it activates something like

function items() {
  player.additem xxxxxx;
  player.additem xxxxxx;
  player.additem xxxxxx;
}

Or even just be able to store and call a variable via command line like:

$gem=player.additem 2E504 10;
$gem;

Solution 1:

I'm not aware of a way to use variables, but it is possible to create function-like batch scripts.

This can be done by creating an ordinary text file containing the commands you wish to run together (one per line, CRLF, no other delimiters). Save this file as e.g. myscript.txt in your Skyrim folder (in the same location as TESV.exe). In-game, you can then run this script via the bat console command:

bat myscript

Unfortunately, this does not appear to support arguments, so cannot be parameterized.