René J.V. Bertin wrote on 20260917::12:45:57 re: "Re: relative path from absolute path, in tcl?"
>On Thursday September 17 2026 09:40:25 Joshua Root wrote: > >><https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/fileutil/fileutil.md#19> > >Ah yes, that's not a generic solution but should work in my intended context, >thanks. Actually, `::fileutil::stripPath $prefix $path` is just a fancy implementation of `[string map [list $prefix ""] $path]`, no? This would be the actual function that does the trick for me: ``` proc makeRelativeTo {refPath targetPath} { ##package require fileutil return [file join ".." [::fileutil::stripPath [file dirname ${refPath}] ${targetPath}]] } ``` (turns out the package has already been loaded in a way that leaves it accessible.) For future reference: I found this discussion with a generic implementation, in several languages (not including Tcl): https://mrpmorris.blogspot.com/2007/05/convert-absolute-path-to-relative-path.html R.
