Windows CMD:从绝对路径获取相对路径 [英] Windows CMD: Get relative path from absolute path

查看:3051
本文介绍了Windows CMD:从绝对路径获取相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从绝对路径获取相对路径,例如。将C:\absolute\path\file.ext转换为路径?

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

感谢您考虑

编辑:我想递归地扫描某个文件类型的目录,然后为包含此文件类型的这些文件夹创建符号链接。

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.

推荐答案

此函数的工作原理

DosTips.com:MakeRelative



然后它为每个不匹配的部分添加.. \。

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

这篇关于Windows CMD:从绝对路径获取相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆