I'll add documentdata.variable so that one can do this: \setupdocument [id=foo] \startluacode luatex.wrapup(function() local id = documentdata.variable("id") if id and id ~= "" then local oldname = file.addsuffix(environment.jobname,"pdf") local newname = file.addsuffix("doc-"..id,"pdf") if lfs.isfile(newname) then -- print("removing",newname) os.remove(newname) end if not lfs.isfile(newname) then -- print("renaming",oldname,newname) os.rename(oldname,newname) end if not lfs.isfile(newname) then -- print("error in renaming") end end end) \stopluacode \starttext test \stoptext -- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------