From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: Variable in file name for babel output? Date: Fri, 28 Jun 2013 01:07:54 +0200 Message-ID: <8761wzi245.fsf@med.uni-goettingen.de> References: <87y59vr9ve.fsf@hornfels.zedat.fu-berlin.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsLIQ-0000Zj-2L for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 19:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsLIO-0003qk-S2 for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 19:08:10 -0400 Received: from plane.gmane.org ([80.91.229.3]:52343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsLIO-0003qC-Lm for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 19:08:08 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UsLIN-00072n-5I for emacs-orgmode@gnu.org; Fri, 28 Jun 2013 01:08:07 +0200 Received: from vpn-2053.gwdg.de ([134.76.2.53]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 28 Jun 2013 01:08:07 +0200 Received: from andreas.leha by vpn-2053.gwdg.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 28 Jun 2013 01:08:07 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi Loris, "Loris Bennett" writes: > Hi, > > Is it possible to pass a variable to a source block such that the > variable can be used as part of the name of the output file? > > Currently I have > > #+HEADER: :var data=timelimit-elapsed-data year=2011 :colnames yes > #+HEADER: :session *r* :file (org-babel-temp-file "time-elapsed-" ".pdf") > > which gets me a different name for each value of 'year', but ideally I > would like the files to be called > > time-elapsed-2011.pdf > time-elapsed-2012.pdf > time-elapsed-2013.pdf > > etc. > > Can this be done? Maybe not what you are looking for, but you could handle the assembly of the filename within your code block. Something like: #+HEADER: :var year=2011 :session *r* :results file #+begin_src R filename <- paste0("time-elapsed-", year, ".pdf") pdf(filename) ## your code dev.off() filename #+end_src Regards, Andreas