批处理文件换行问题 [英] Batch file new line problems
问题描述
我现在正在拔头发.
我有一个批处理文件,该文件搜索子目录以查找jpg文件,然后使用找到的文件名解析一些简单的HTML代码并将其推送到文本文件中.
I have a batch file that searches through sub directories looking for jpg files and then parses some simple HTML code using the file names it finds and pushes this to a text file.
至关重要的是,每个创建的文件的每一行都由空白行分隔.
It is vitally important that each line of every file created is separated by a blank line.
这就是为什么我包含回声"的原因.线.请参阅下面的批处理文件代码:
This is why I have included the "Echo." lines. See batch file code below:
pushd \\SRVAPP1\Image Archive
Echo %CD%
PAUSE
for /R %CD% %%F in (*.jpg) do (
Echo %%~nF
Echo.
Echo ^<html^>^<img src='^.%%~pnxF' ^>^<a href='^.%%~pnxF'^>Download file^<^/a^>^<^/html^>
Echo.
Echo ^[^[Open file^|file^:^.%%~pnxF^]^]
Echo.
Echo ^[^[Show in folder^|file^:^.%%~pF^]^]
) > ".\Documentation\%%~nF.tid"
popd
PAUSE
循环会循环遍历第一个子目录,并创建一个完美的输出.下面的例子
The loop iterates through the first sub directory fine and creates a perfect output. example below
YORYM_TA1
<html><img src='.\2014-03-13\JPG\YORYM_TA1.jpg' ><a href='.\2014-03-13\JPG\YORYM_TA1.jpg'>Download file</a></html>
[[Open file|file:.\2014-03-13\JPG\YORYM_TA1.jpg]]
[[Show in folder|file:.\2014-03-13\JPG\]]
但是,当批处理文件移至第二个目录-以及所有后续目录"Echo"时.似乎被"Echo .."代替,您将获得以下输出(用句号代替空行来完成):
However, when the batch file moves onto the second directory - and all subsequent directories "Echo." seems to be replaced by "Echo.." and you get the following output (complete with full stops instead of blank lines):
YORYM_H2200_8
.
<html><img src='.\2014-05-22\JPG\YORYM_H2200_8.jpg' ><a href='.\2014-05-22\JPG\YORYM_H2200_8.jpg'>Download file</a></html>
.
[[Open file|file:.\2014-05-22\JPG\YORYM_H2200_8.jpg]]
.
[[Show in folder|file:.\2014-05-22\JPG\]]
有什么想法可能会发生这种情况吗?我正在运行Windows 7.
Any ideas why this may be occurring? I am running windows 7.
推荐答案
使用echo.
可能会出现问题,因为它每次在磁盘上搜索名为echo
的文件时都没有扩展名.如果有这样的文件,echo.
只会失败.
Using echo.
can be problematic, as it searches each time on the disk for a file named echo
without an extension. If there is such a file echo.
will simply fail.
echo(
更快,更安全.
对于echo
的所有其他组合,您可以阅读
剂量提示:回声.无法输入文本或空白行-而是使用ECHO/
For all the other combinations off echo
you could read
Dostips: ECHO. FAILS to give text or blank line - Instead use ECHO/
这篇关于批处理文件换行问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!