UNIX mkdir
has the -p
flag that creates the parent directories if they don't exist. Is there an equivalent in cleartool for that? Obviously cleartool mkdir foo/bar/
doens't work when foo
doesn't already exist.

- 1,866
- 21
- 36
2 Answers
The simplest way is to create a file in the directory structure and use mkelem -mkpath...
I created a "temp1" directory, and a "temp2" directory, and a "temp.txt" file in one of my sandbox vobs, then added the file to source control with -mkpath from the parent of the "temp1" view private directory.
PS M:\tempview\foobarf\Documents> cleartool mkelem -mkpath .\temp1\temp2\temp.txt
Creating parent directory element ".\temp1\temp2".
Creating parent directory element ".\temp1".
Created directory element ".\temp1".
Checking out parent directory ".\temp1".
Created directory element ".\temp1\temp2".
Checking out parent directory ".\temp1\temp2".
Creation comments for ".\temp1\temp2\temp.txt":
Test1.
.
Created element ".\temp1\temp2\temp.txt" (type "utf16le_file").
Checked out ".\temp1\temp2\temp.txt" from version "\main\0".
It's UTF-16LE because Powershell's Locale is wide character and the "temp.txt" was created using "dir > temp1\temp2\temp.txt".

- 1,048
- 6
- 7
-
Thanks, I think this is what I need, I just need some time to test. – Stelios Adamantidis Apr 12 '19 at 10:26
-
No sorry, it doesn't work for creating a directory _only_. `Unable to determine view for "foo/bar/": No such file or directory.` – Stelios Adamantidis Apr 15 '19 at 13:47
-
1@SteliosAdamantidis Any particular reason for needing an empty directory structure as VOB objects? Winkins don't need the directories to exist, you'll see messages like "created directory .. for derived object winkin". – Brian Cowan Apr 16 '19 at 14:22
-
Sure! I _already_ have some files _elsewhere_ and I want to move them there. – Stelios Adamantidis Apr 16 '19 at 14:26
-
Why not simply create and then remove a bogus file with this command line? `dir > foo\bar\oof\deleteme & cleartool mkelem -mkpath -ci -nc foo\bar\oof\deleteme &cleartool rmelem foo\bar\oof\deleteme` – Brian Cowan Apr 17 '19 at 20:11
-
Because I could more "simply" create a script that will get a `/very/annoyingly/big/directory/` and stack the `ct mkdir` calls in there. I am looking for a missing `-p` of `ct mkdir`. If it doesn't exist then it doesn't. It's clearcase after all, I can't expect much... – Stelios Adamantidis Apr 18 '19 at 07:35
-
Please create a Request for Enhancement (RFE) in the RFE community at [link](https://www.ibm.com/developerworks/rfe/) It really boils down to "noone has asked for this..." And IBM/HCL likes RFE's because they mean people are using the toolset. – Brian Cowan Apr 18 '19 at 13:38
cleartool mkelem -mkpath
is a good option when adding one file.
But if you have multiple files to add, in a tree structure which does not exist yet, don't forget about clearfsimport
: it can import flat files to a branch in one command, and will create any missing folder for you.
As seen here: clearfsimport -rec -nset <Source> <target>

- 1,262,500
- 529
- 4,410
- 5,250
-
Thanks for this answer, _but_ I already found your suggestion of `clearfsimport` in another answer and I don't find it useful. I just need to avoid stacking the `mkdir`s not interested in the tree. :) – Stelios Adamantidis Apr 12 '19 at 10:25