5

If I create a folder inside Templates, when I click "new Document" > "myfolder" it does nothing. That is just a sub directory to organize the templates.

But maybe it would be useful to create that folder hierarchy. For instance:

I have all these files and folders:

  • ~/template/tm1.txt
  • ~/template/tm2.txt
  • ~/template/myfolder/
  • ~/template/myfolder/subfolder/
  • ~/template/myfolder/subfolder/hello1.html
  • ~/template/myfolder/subfolder/hello2.html
  • ~/template/myfolder/subfolder/hello3.html
  • ~/template/myfolder/index.html

So when I click "new Document" > "myfolder" I'd like to create "myfolder" with "subfolder" and index.html (etc....).

Is there any way to do this?

I know that "new Document" isn't the same as "new folder", but maybe this should be called "new template".

Glutanimate
  • 21,393
  • Not as elegant as other answers but simple. You can create a compressed file with directories inside and create a copy from the template and immediately uncompress it (with right click) (and delete the compressed file). – alfC Jul 22 '21 at 03:19

2 Answers2

1

I don't think this is possible via the Templates menu but you could create a Nautilus script to achieve the same. Something akin to the following should work:

#!/bin/bash

# Create folder structure from template

TemplateDir="$HOME/Folder templates/dir1"
WorkingDir="$PWD"

cp -r "$TemplateDir" "$WorkingDir/"

Place your folder with subfolders and files in ~/Folder templates and modify the TemplateDir line accordingly. Then follow these instructions to install the script.

When you're done, right click on an empty area in your Nautilus window and select Scriptsyour script name. This should create a copy of your template directory in the current folder.

Glutanimate
  • 21,393
1

I have a Nautilus extension that hopefully does what you're looking for. See the following website:

nautilus-new-folder-from-template

This extension allows you to create directory-templates, and choose from among them using the right-click context menu.

Mark
  • 1,469
  • Doesn't work. It looks like it would without nautilus-new-folder-from-template: http://i.imgur.com/xHTx7tU.png (Yes, I restarted Nautilus.) – UTF-8 Nov 11 '16 at 12:18
  • hi @Mark, this repository is no longer (publicly) available. Has it been moved somewhere else? – dukwon Oct 14 '20 at 11:52
  • @dukwon - the URL (and code) is now updated and should be working correctly with Ubuntu 20.04. To UTF-8: the image you show indicates that the (old version of the) extension failed to load. – Mark Oct 23 '20 at 17:12