简体   繁体   English

Windows批处理脚本url解码

[英]Windows batch script url decoding

I have a batch script that triggers vlc for me on my network, the problem is it opens based on URLs in a browser. 我有一个批处理脚本在我的网络上为我触发vlc,问题是它是基于浏览器中的URL打开的。 The browser automatically adds the %20 in place of a regular space, and I need to replace this with a regular space again in my batch script before sending the file path on to vlc. 浏览器会自动添加%20来代替常规空间,在将文件路径发送到vlc之前,我需要在批处理脚本中再次使用常规空格替换它。

Here is my code; 这是我的代码;

@echo off
set str=%1
set str=%str:~8%
set str=%str:%%20= %
START /D "C:\Program Files\VideoLAN\VLC\" vlc.exe %str%
pause

It is worth mentioning that this will run on a windows 7 and/or vista system. 值得一提的是,这将在Windows 7和/或vista系统上运行。

@echo off
setlocal enabledelayedexpansion
set str=%~1
set str=%str:~7%
set str=!str:%%20= !
"C:\Program Files\VideoLAN\VLC\vlc.exe" "%str%"
pause

Took the liberty of fixing some other things as well. 也可以自由修复其他一些事情。 If the script ran with quotes around the argument it always had a trailing " . Delayed expansion gives you a second set of variable delimiters here which avoids the trouble with the % . Furthermore, start isn't needed as far as I can see, unless you critically depend on VLC having its own directory as its startup path. 如果脚本在参数周围用引号运行,它总是有一个尾随" 。延迟扩展在这里为你提供了第二组变量分隔符,这避免了% 。此外, start我所见,不需要start ,除非你严格依赖于VLC有自己的目录作为它的启动路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM