Windows CMD: Get relative path from absolute path

人走茶凉 提交于 2019-12-22 05:14:43

问题


How do i obtain the relative path from an absolute path, e.g. convert 'C:\absolute\path\file.ext' to 'path'?

Thanks for your consideration

edit: i'd like to recursivly scan a directory for a certain filetype and then create symlinks for these folders containing this filetype. the symlinks should be named like the directory containing the filetype.


回答1:


This function works
DosTips.com :MakeRelative

It compares both pathes and removes the identical front.
Then it adds "..\" for each non matching part.



来源:https://stackoverflow.com/questions/4816541/windows-cmd-get-relative-path-from-absolute-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!