In this thread you will find the following code. What I would like to change is that the pdf and html will not go to that folder. Place only service files such as tex files there.

(defun org-export-output-file-name-modified (orig-fun extension &optional subtreep pub-dir)
  (unless pub-dir
    (setq pub-dir "exported-org-files")
    (unless (file-directory-p pub-dir)
      (make-directory pub-dir)))
  (apply orig-fun extension subtreep pub-dir nil))
(advice-add 'org-export-output-file-name :around #'org-export-output-file-name-modified)

Some idea?

  • 1
    Because of how org-latex-export-to-pdf has been implemented, which passes #'org-latex-compile as the POST-PROCESS argument in org-export-to-file, what you are asking is a little cumbersome to achieve. Maybe you could use (setq org-latex-remove-logfiles t), to remove most 'service files'? Would that be sufficient? Commented Feb 10 at 8:42
  • It is an idea that I have been considering, but it is not ideal because sometimes you have to analyze the .tex files. A colleague has made a code in Lisp so that once compiled it moves the files to a folder which I have hidden for greater cleanliness. It is not an ideal solution because it is not native but it works.
    – Levo
    Commented Feb 10 at 12:40

1 Answer 1


This code works, but how i say no it's a native solution

(defun org-latex-move-exported-files (&optional arg)        
  "Mueve los archivos generados por latex a un directorio al final de la exportación." 
  (ignore arg)                                                                      
  (let ((latex-output-dir "./latex/")             
        (latex-files (directory-files "." nil "\\.lot\\|\\.lof\\|\\.tex\\|\\.log\\|\\.aux\\|\\.out\\|\\.toc"))) 
    (unless (file-exists-p "./.latex/")                         
      (mkdir ".latex" "."))
    (when latex-files                              
      (dolist (file latex-files)  
        (when (file-exists-p file)  
          (rename-file file (concat latex-output-dir (file-name-nondirectory file)) t)))  (message "Se movieron los archivos de LaTeX generados por Org al directorio ./latex/"))))
(advice-add 'org-export-dispatch :after 'org-latex-move-exported-files)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.