Tool for creating and calling folder structure templates?












1















Is there a Linux utility for creating templates for directory structures, outside of the scripts packaged with a DE like Gnome or LXDE? (I run openbox and would like to avoid a DE at all costs)



There is this post talking about template files, which I will absolutely use, and there is the template toolkit but that's more for documents and dynamic web content (although, it can be easily extended).



I'm looking for something to encompass whole directory structures as well.



Say I have a C template directory structure like so:



prj_?    
Doxyfile
Makefile
README
bin
data
doc
include
src


Or a nodejs template structure like:



index.html
js/
main.js
models/
views/
collections/
templates/
libs/
backbone/
underscore/
...
css/
...


Surely there must be something available, given that folders like /skel exist... or is that yet another manually scripted section of Linux?



If this doesn't yet exist, I would love to contribute to the community by writing and maintaining a tool of this nature, or at the very least writing a vim plugin to handle such functionality (spoiler alert: doesn't exist), but that would be something to discuss on the vim exchange.










share|improve this question

























  • I suspect a shell script with a mkdir -p call is common. Unclear what the advantage over that would be; could you clarify a little what you envision?

    – derobert
    Jan 7 at 18:14













  • yeh sure... I mean, calling mkdir -p for every single differing template would just be laborious and essentially repeated work. By the same token, as you mentioned, this would be a fairly common thing that many people would do hence a small tool with some config file options would be helpful. I would envision a small CL tool, with definitions for file types. I could imagine a syntax like <command> <filetype i.e. C, HTML etc> <directory>. I would add hooks functionalities for git and vim, and config files could be in yml or json.

    – Medicineman25
    Jan 7 at 18:20











  • Well, you save the mkdir -p line in a script file, so you don't ever have to retype it. You're basically just passing it a list of directory names, so hard to get shorter than that. Or alternatively, you have a built-out directory tree and want to duplicated it, but that's what cp -r does. (/etc/skel, BTW, at least on Debian is implemented by account creation script adduser, a perl script — it just copies the files in a rather weird way, probably it can't depend on File::Find being available). Catalyst (perl MVC framework) does have its app setup script, which does something similar...

    – derobert
    Jan 7 at 18:25













  • yeh I figured as much... that's cool, just wanted to see if I was missing something obvious. I'll definitely have a dig through useradd/adduser (Arch/Debian) and see what I can make of perl. Thanks for clarifying! :)

    – Medicineman25
    Jan 7 at 18:33
















1















Is there a Linux utility for creating templates for directory structures, outside of the scripts packaged with a DE like Gnome or LXDE? (I run openbox and would like to avoid a DE at all costs)



There is this post talking about template files, which I will absolutely use, and there is the template toolkit but that's more for documents and dynamic web content (although, it can be easily extended).



I'm looking for something to encompass whole directory structures as well.



Say I have a C template directory structure like so:



prj_?    
Doxyfile
Makefile
README
bin
data
doc
include
src


Or a nodejs template structure like:



index.html
js/
main.js
models/
views/
collections/
templates/
libs/
backbone/
underscore/
...
css/
...


Surely there must be something available, given that folders like /skel exist... or is that yet another manually scripted section of Linux?



If this doesn't yet exist, I would love to contribute to the community by writing and maintaining a tool of this nature, or at the very least writing a vim plugin to handle such functionality (spoiler alert: doesn't exist), but that would be something to discuss on the vim exchange.










share|improve this question

























  • I suspect a shell script with a mkdir -p call is common. Unclear what the advantage over that would be; could you clarify a little what you envision?

    – derobert
    Jan 7 at 18:14













  • yeh sure... I mean, calling mkdir -p for every single differing template would just be laborious and essentially repeated work. By the same token, as you mentioned, this would be a fairly common thing that many people would do hence a small tool with some config file options would be helpful. I would envision a small CL tool, with definitions for file types. I could imagine a syntax like <command> <filetype i.e. C, HTML etc> <directory>. I would add hooks functionalities for git and vim, and config files could be in yml or json.

    – Medicineman25
    Jan 7 at 18:20











  • Well, you save the mkdir -p line in a script file, so you don't ever have to retype it. You're basically just passing it a list of directory names, so hard to get shorter than that. Or alternatively, you have a built-out directory tree and want to duplicated it, but that's what cp -r does. (/etc/skel, BTW, at least on Debian is implemented by account creation script adduser, a perl script — it just copies the files in a rather weird way, probably it can't depend on File::Find being available). Catalyst (perl MVC framework) does have its app setup script, which does something similar...

    – derobert
    Jan 7 at 18:25













  • yeh I figured as much... that's cool, just wanted to see if I was missing something obvious. I'll definitely have a dig through useradd/adduser (Arch/Debian) and see what I can make of perl. Thanks for clarifying! :)

    – Medicineman25
    Jan 7 at 18:33














1












1








1








Is there a Linux utility for creating templates for directory structures, outside of the scripts packaged with a DE like Gnome or LXDE? (I run openbox and would like to avoid a DE at all costs)



There is this post talking about template files, which I will absolutely use, and there is the template toolkit but that's more for documents and dynamic web content (although, it can be easily extended).



I'm looking for something to encompass whole directory structures as well.



Say I have a C template directory structure like so:



prj_?    
Doxyfile
Makefile
README
bin
data
doc
include
src


Or a nodejs template structure like:



index.html
js/
main.js
models/
views/
collections/
templates/
libs/
backbone/
underscore/
...
css/
...


Surely there must be something available, given that folders like /skel exist... or is that yet another manually scripted section of Linux?



If this doesn't yet exist, I would love to contribute to the community by writing and maintaining a tool of this nature, or at the very least writing a vim plugin to handle such functionality (spoiler alert: doesn't exist), but that would be something to discuss on the vim exchange.










share|improve this question
















Is there a Linux utility for creating templates for directory structures, outside of the scripts packaged with a DE like Gnome or LXDE? (I run openbox and would like to avoid a DE at all costs)



There is this post talking about template files, which I will absolutely use, and there is the template toolkit but that's more for documents and dynamic web content (although, it can be easily extended).



I'm looking for something to encompass whole directory structures as well.



Say I have a C template directory structure like so:



prj_?    
Doxyfile
Makefile
README
bin
data
doc
include
src


Or a nodejs template structure like:



index.html
js/
main.js
models/
views/
collections/
templates/
libs/
backbone/
underscore/
...
css/
...


Surely there must be something available, given that folders like /skel exist... or is that yet another manually scripted section of Linux?



If this doesn't yet exist, I would love to contribute to the community by writing and maintaining a tool of this nature, or at the very least writing a vim plugin to handle such functionality (spoiler alert: doesn't exist), but that would be something to discuss on the vim exchange.







filesystems directory directory-structure utilities template






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 8 at 0:09









Rui F Ribeiro

39.5k1479132




39.5k1479132










asked Jan 7 at 17:48









Medicineman25Medicineman25

133




133













  • I suspect a shell script with a mkdir -p call is common. Unclear what the advantage over that would be; could you clarify a little what you envision?

    – derobert
    Jan 7 at 18:14













  • yeh sure... I mean, calling mkdir -p for every single differing template would just be laborious and essentially repeated work. By the same token, as you mentioned, this would be a fairly common thing that many people would do hence a small tool with some config file options would be helpful. I would envision a small CL tool, with definitions for file types. I could imagine a syntax like <command> <filetype i.e. C, HTML etc> <directory>. I would add hooks functionalities for git and vim, and config files could be in yml or json.

    – Medicineman25
    Jan 7 at 18:20











  • Well, you save the mkdir -p line in a script file, so you don't ever have to retype it. You're basically just passing it a list of directory names, so hard to get shorter than that. Or alternatively, you have a built-out directory tree and want to duplicated it, but that's what cp -r does. (/etc/skel, BTW, at least on Debian is implemented by account creation script adduser, a perl script — it just copies the files in a rather weird way, probably it can't depend on File::Find being available). Catalyst (perl MVC framework) does have its app setup script, which does something similar...

    – derobert
    Jan 7 at 18:25













  • yeh I figured as much... that's cool, just wanted to see if I was missing something obvious. I'll definitely have a dig through useradd/adduser (Arch/Debian) and see what I can make of perl. Thanks for clarifying! :)

    – Medicineman25
    Jan 7 at 18:33



















  • I suspect a shell script with a mkdir -p call is common. Unclear what the advantage over that would be; could you clarify a little what you envision?

    – derobert
    Jan 7 at 18:14













  • yeh sure... I mean, calling mkdir -p for every single differing template would just be laborious and essentially repeated work. By the same token, as you mentioned, this would be a fairly common thing that many people would do hence a small tool with some config file options would be helpful. I would envision a small CL tool, with definitions for file types. I could imagine a syntax like <command> <filetype i.e. C, HTML etc> <directory>. I would add hooks functionalities for git and vim, and config files could be in yml or json.

    – Medicineman25
    Jan 7 at 18:20











  • Well, you save the mkdir -p line in a script file, so you don't ever have to retype it. You're basically just passing it a list of directory names, so hard to get shorter than that. Or alternatively, you have a built-out directory tree and want to duplicated it, but that's what cp -r does. (/etc/skel, BTW, at least on Debian is implemented by account creation script adduser, a perl script — it just copies the files in a rather weird way, probably it can't depend on File::Find being available). Catalyst (perl MVC framework) does have its app setup script, which does something similar...

    – derobert
    Jan 7 at 18:25













  • yeh I figured as much... that's cool, just wanted to see if I was missing something obvious. I'll definitely have a dig through useradd/adduser (Arch/Debian) and see what I can make of perl. Thanks for clarifying! :)

    – Medicineman25
    Jan 7 at 18:33

















I suspect a shell script with a mkdir -p call is common. Unclear what the advantage over that would be; could you clarify a little what you envision?

– derobert
Jan 7 at 18:14







I suspect a shell script with a mkdir -p call is common. Unclear what the advantage over that would be; could you clarify a little what you envision?

– derobert
Jan 7 at 18:14















yeh sure... I mean, calling mkdir -p for every single differing template would just be laborious and essentially repeated work. By the same token, as you mentioned, this would be a fairly common thing that many people would do hence a small tool with some config file options would be helpful. I would envision a small CL tool, with definitions for file types. I could imagine a syntax like <command> <filetype i.e. C, HTML etc> <directory>. I would add hooks functionalities for git and vim, and config files could be in yml or json.

– Medicineman25
Jan 7 at 18:20





yeh sure... I mean, calling mkdir -p for every single differing template would just be laborious and essentially repeated work. By the same token, as you mentioned, this would be a fairly common thing that many people would do hence a small tool with some config file options would be helpful. I would envision a small CL tool, with definitions for file types. I could imagine a syntax like <command> <filetype i.e. C, HTML etc> <directory>. I would add hooks functionalities for git and vim, and config files could be in yml or json.

– Medicineman25
Jan 7 at 18:20













Well, you save the mkdir -p line in a script file, so you don't ever have to retype it. You're basically just passing it a list of directory names, so hard to get shorter than that. Or alternatively, you have a built-out directory tree and want to duplicated it, but that's what cp -r does. (/etc/skel, BTW, at least on Debian is implemented by account creation script adduser, a perl script — it just copies the files in a rather weird way, probably it can't depend on File::Find being available). Catalyst (perl MVC framework) does have its app setup script, which does something similar...

– derobert
Jan 7 at 18:25







Well, you save the mkdir -p line in a script file, so you don't ever have to retype it. You're basically just passing it a list of directory names, so hard to get shorter than that. Or alternatively, you have a built-out directory tree and want to duplicated it, but that's what cp -r does. (/etc/skel, BTW, at least on Debian is implemented by account creation script adduser, a perl script — it just copies the files in a rather weird way, probably it can't depend on File::Find being available). Catalyst (perl MVC framework) does have its app setup script, which does something similar...

– derobert
Jan 7 at 18:25















yeh I figured as much... that's cool, just wanted to see if I was missing something obvious. I'll definitely have a dig through useradd/adduser (Arch/Debian) and see what I can make of perl. Thanks for clarifying! :)

– Medicineman25
Jan 7 at 18:33





yeh I figured as much... that's cool, just wanted to see if I was missing something obvious. I'll definitely have a dig through useradd/adduser (Arch/Debian) and see what I can make of perl. Thanks for clarifying! :)

– Medicineman25
Jan 7 at 18:33










1 Answer
1






active

oldest

votes


















2














The mtree(1) utility is standard on BSD systems, and I'm pretty sure it ought to be available for Linux as well somewhere. It reads a directory hierarchy specification and compares it with what's found on disk, optionally deleting files (or updating their permissions or ownership) and creating missing directories as needed.



Its specification does not quite look like what you have. The specification for an /etc directory, as found on an OpenBSD base system, would look like



/set type=dir uname=root gname=wheel mode=0755
.
etc
X11
app-defaults
..
twm
..
xenodm
pixmaps
..
..
xinit
..
xsm
..
..
fonts
conf.avail
..
conf.d
..
..
..


That would be the tool for creating empty directories (mtree -d -u -f spec_file or something similar). If you want to create something like a populated directory hierarchy from some skeleton directory, I would use a tar archive of the skeleton directory and just unpack that at the destination.



An existing skeleton directory can be copied with pax easily:



( cd -- "$skel_dir" && pax -rw -p p . "$dest_dir" )





share|improve this answer





















  • 1





    Heck to the yes my dude, this is exactly what I'm looking for... you legend!!

    – Medicineman25
    Jan 7 at 18:39











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493045%2ftool-for-creating-and-calling-folder-structure-templates%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














The mtree(1) utility is standard on BSD systems, and I'm pretty sure it ought to be available for Linux as well somewhere. It reads a directory hierarchy specification and compares it with what's found on disk, optionally deleting files (or updating their permissions or ownership) and creating missing directories as needed.



Its specification does not quite look like what you have. The specification for an /etc directory, as found on an OpenBSD base system, would look like



/set type=dir uname=root gname=wheel mode=0755
.
etc
X11
app-defaults
..
twm
..
xenodm
pixmaps
..
..
xinit
..
xsm
..
..
fonts
conf.avail
..
conf.d
..
..
..


That would be the tool for creating empty directories (mtree -d -u -f spec_file or something similar). If you want to create something like a populated directory hierarchy from some skeleton directory, I would use a tar archive of the skeleton directory and just unpack that at the destination.



An existing skeleton directory can be copied with pax easily:



( cd -- "$skel_dir" && pax -rw -p p . "$dest_dir" )





share|improve this answer





















  • 1





    Heck to the yes my dude, this is exactly what I'm looking for... you legend!!

    – Medicineman25
    Jan 7 at 18:39
















2














The mtree(1) utility is standard on BSD systems, and I'm pretty sure it ought to be available for Linux as well somewhere. It reads a directory hierarchy specification and compares it with what's found on disk, optionally deleting files (or updating their permissions or ownership) and creating missing directories as needed.



Its specification does not quite look like what you have. The specification for an /etc directory, as found on an OpenBSD base system, would look like



/set type=dir uname=root gname=wheel mode=0755
.
etc
X11
app-defaults
..
twm
..
xenodm
pixmaps
..
..
xinit
..
xsm
..
..
fonts
conf.avail
..
conf.d
..
..
..


That would be the tool for creating empty directories (mtree -d -u -f spec_file or something similar). If you want to create something like a populated directory hierarchy from some skeleton directory, I would use a tar archive of the skeleton directory and just unpack that at the destination.



An existing skeleton directory can be copied with pax easily:



( cd -- "$skel_dir" && pax -rw -p p . "$dest_dir" )





share|improve this answer





















  • 1





    Heck to the yes my dude, this is exactly what I'm looking for... you legend!!

    – Medicineman25
    Jan 7 at 18:39














2












2








2







The mtree(1) utility is standard on BSD systems, and I'm pretty sure it ought to be available for Linux as well somewhere. It reads a directory hierarchy specification and compares it with what's found on disk, optionally deleting files (or updating their permissions or ownership) and creating missing directories as needed.



Its specification does not quite look like what you have. The specification for an /etc directory, as found on an OpenBSD base system, would look like



/set type=dir uname=root gname=wheel mode=0755
.
etc
X11
app-defaults
..
twm
..
xenodm
pixmaps
..
..
xinit
..
xsm
..
..
fonts
conf.avail
..
conf.d
..
..
..


That would be the tool for creating empty directories (mtree -d -u -f spec_file or something similar). If you want to create something like a populated directory hierarchy from some skeleton directory, I would use a tar archive of the skeleton directory and just unpack that at the destination.



An existing skeleton directory can be copied with pax easily:



( cd -- "$skel_dir" && pax -rw -p p . "$dest_dir" )





share|improve this answer















The mtree(1) utility is standard on BSD systems, and I'm pretty sure it ought to be available for Linux as well somewhere. It reads a directory hierarchy specification and compares it with what's found on disk, optionally deleting files (or updating their permissions or ownership) and creating missing directories as needed.



Its specification does not quite look like what you have. The specification for an /etc directory, as found on an OpenBSD base system, would look like



/set type=dir uname=root gname=wheel mode=0755
.
etc
X11
app-defaults
..
twm
..
xenodm
pixmaps
..
..
xinit
..
xsm
..
..
fonts
conf.avail
..
conf.d
..
..
..


That would be the tool for creating empty directories (mtree -d -u -f spec_file or something similar). If you want to create something like a populated directory hierarchy from some skeleton directory, I would use a tar archive of the skeleton directory and just unpack that at the destination.



An existing skeleton directory can be copied with pax easily:



( cd -- "$skel_dir" && pax -rw -p p . "$dest_dir" )






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 7 at 18:41

























answered Jan 7 at 18:34









KusalanandaKusalananda

124k16234386




124k16234386








  • 1





    Heck to the yes my dude, this is exactly what I'm looking for... you legend!!

    – Medicineman25
    Jan 7 at 18:39














  • 1





    Heck to the yes my dude, this is exactly what I'm looking for... you legend!!

    – Medicineman25
    Jan 7 at 18:39








1




1





Heck to the yes my dude, this is exactly what I'm looking for... you legend!!

– Medicineman25
Jan 7 at 18:39





Heck to the yes my dude, this is exactly what I'm looking for... you legend!!

– Medicineman25
Jan 7 at 18:39


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493045%2ftool-for-creating-and-calling-folder-structure-templates%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Morgemoulin

Scott Moir

Souastre