Skip to content

Instantly share code, notes, and snippets.

@sshaw
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshaw/5799c2fc39c226823e29 to your computer and use it in GitHub Desktop.
Save sshaw/5799c2fc39c226823e29 to your computer and use it in GitHub Desktop.
Syntax for creating directory trees
# /a/b.txt
# /a/c.txt
# /a/d/e/
# /a/d/f.txt
:a => [
"b.txt",
"c.txt",
:d => [ "e/", "f.txt" ]
]
:a => [
{"b.txt" => "Test file contents"},
{"c.txt" => {:size => "16K", :chmod => 0600}},
{:d => [ "f.txt" ]},
"d/e"
]
# Random names
"%d" => [ "%f", "%d" ]
"%d/{%f, %f.txt, %f.jpg}"
# Random names + reuse
"%d:1/{%f, :1.txt, :1.jpg }"
"%d:1/%d:2/%d"
"%d:1/%d:2/{x.txt, :2.txt}"
# X123_865765746/865765746.xml
# X123_865765746/resources/865765746_1.mp3
# X123_865765746/resources/865765746_2.mp3
#
# Generate random sequence of length 9 and reuse
"X123_%9s:1" => [
":1.xml",
"resources" => [":1_1.mp3", ":1_2.mp3"]
]
# a/file1.txt
# a/file2.txt
# ...
# a/file10.txt
:a => [
{ "file" * 10 } # or
{ "file" => (1..10) }, # or
{ "file%n" => (1..10) }, # or
{ "file" => 10 }, # or
{ 10 => "file" }, # or
{ (1..10) => "file" }
]
# Variable names
# also :{id}
":id" => [
":id.xml",
{"resources" => [ ":id.jpg", ":id.wmv" ]
]
# YYMMDD_EPOCHSECS.txt
"%Y%M%D_%S.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment