Trying to create a nested directory structure YEAR/FILE_TYPE.
Desired Directory Structure:
~/2016/doc
~/2016/pdf
~/2016/txt
~/2015/doc
~/2015/pdf
~/2015/txt
etc...
create by YEAR variable with: set varYear (seq 1996 2016) # fish shell syntax
create File Type variable set varType (doc pdf txt) # fish shell syntax
1st failed attempt: running echo "mkdir /"$varDate/$varType
2nd failed attempt: for i in $varDate echo $i "/" $varType end # fish shell syntax
Would appreciate some help on how to combine the two variables together in a for loop to create the directory structure.
$ set years 2015 2016
$ set subdirs doc pdf txt
$ echo {$years}/{$subdirs}
2015/doc 2016/doc 2015/pdf 2016/pdf 2015/txt 2016/txt
Just replace echo with mkdir -p.
See https://fishshell.com/docs/current/index.html#expand-variable
and https://fishshell.com/docs/current/index.html#expand-brace
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With