仅接收 shell 命令中的文件名
在某些文件扩展名上运行 shell 命令时(在它的上下文菜单中),我只想获取文件名(而不是完整路径) 它可能以某种方式在注册表中、在 HKCR 下的文件扩展名中完成。 %1 %l %L 中的任何一个都给出完整路径。我只想要文件名,
谢谢
这个想法很好,但我无法让它工作
我创建了文件 - GetFileName.bat
我把它放在 %path%
中的某个地方,
它看起来像这样: @set Ret="%~n1"
并在注册表中输入以下命令
cmd /k GetFileName "%L" & hh.exe -decompile 提取了 %Ret%
这意味着: * 运行这个 - GetFileName "%L" * 然后- hh.exe -decompile 提取了 %Ret%,
但 %Ret%
没有给我 GetFileName 的结果,尽管它包含具有正确值的环境变量 Ret。
我猜它不允许在注册表中使用这个环境变量,因为它位于同一行
I want to get only the filename (and no the full path) when running a shell command on some file extension (In the context menu of it)
It is probably done somehow in the registry, in the file extension under HKCR. Any of %1 %l %L gives the full path. I want only the filename
thanks
The idea is good, but I can't make it work
I created the file- GetFileName.bat
I put it somewhere it is in the%path%
it looks like that:@set Ret="%~n1"
and in the registry I put the following command
cmd /k GetFileName "%L" & hh.exe -decompile extracted %Ret%
which means:
* Run this- GetFileName "%L"
* and then- hh.exe -decompile extracted %Ret%
but the %Ret%
doesn't give me the result of the GetFileName, although it contains the environment variable Ret with the correct value.
I guess it doesn't allow in the registry to use this environment variable because it is in the same line
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
%~n
修饰符从脚本参数中的路径中提取文件名,但它似乎无法识别其他环境变量,因此您必须将其填充到单独的批处理中文件:getext.bat:
然后
You can use the
%~n
modifier to extract a filename from a path in a script argument, but it does not appear to recognize other environment varaibles, so you'll have to stuff it into a separate batch file:getext.bat:
and then