Code to return drive

Is there a code to return the drive (C:) of a given path?

I expected {sourcepath|\|noterm} to work, but the backslash doesn't get removed.

Background: Some DOS commands require the pure drive, e.g.

subst {sourcepath|\|noterm} /D

will complain about the \.

Noterm keeps the backslash for drive roots as a special case, as a lot of things are confused without it.

You'll probably need to use scripting for this currently, but we should be able to add a "notermroot" or similar to make things easier in the future.

Alright, that'd be nice. How about drive?

And wouldn't drivelabel be useful, too?

I think something that works like the existing noterm would be best, since then you can use it in more places. e.g. {sourcepath|..|notermroot} would give you the parent path without a slash on the end, whether you're in C:\x\y\z or C:\x. When you want the drive letter you can still combine \ and notermroot, but you'll also be able to do other things which wouldn't be possible with a code that always returns only the drive letter.

(I'm not sure if notermroot is the best name for it, but I can't think of a better name at the moment.)

Are there places that's needed in commands? I can't think of many, since the labels are almost always display-only and not fed in to many commands. Might be useful in the destination path when copying things to a backup drive, I guess?

Yes, copying and renaming was what I had in mind.

We've added notermdrive, driveletter and drivelabel for the next update.

Note that these only currently work in commands, not within the Rename dialog (since things like "noterm" don't work and aren't generally needed in Rename). We could add Rename codes for drive letters and labels if needed.

1 Like

That change is in the beta released today: Directory Opus 12.24.1 (Beta)