简体   繁体   English

使用批处理文件在excel中写入数据

[英]write data in excel using batch file

I write a batch file that check a folder that contains some fonts.I want to to write them in excel.but when I run the .bat file, values overwrite the first row?Actually I don't know how to go to the next row! 我写了一个批处理文件,检查包含某些字体的文件夹。我想用excel编写它们。但是当我运行.bat文件时,值覆盖了第一行?实际上我不知道如何转到下一行行! would anyone help me? 有人可以帮我吗? This is the code: 这是代码:

@ echo off
SETLOCAL ENABLEDELAYEDEXPANSION
color 0b

set file=C:\Users\S.R.P\Desktop\input\*
set inpDir=C:\Users\S.R.P\Desktop\input\


set dat=Test.csv
FOR %%i IN ("%file%") DO (
set fontname=%%~ni && set fontname=!fontname: =!
ECHO !fontname!

set fileextension=%%~xi
set  fontfile=!fontname!%%~xi
set outDir=C:\Users\S.R.P\Desktop\ouput\!fontname!\
ECHO !inpDir!%%~ni
echo !fontfile!
ren "!inpDir!%%~ni%%~xi" "!fontfile!"
ECHO !outDir!
ECHO !fontname!!fileextension!
echo "!fontname!","!inpDir!%%~ni">%dat%

echo.>>%dat%
)
pause
>"test.csv" (
  for %%i in ... (
    ...
    ...
  )
)

and remove all >%dat% inside the for loop. 并删除for循环中的所有>%dat% Also, this opens the file only once, whereas each > or >> will open and close the file. 同样,这只会打开文件一次,而每个>>>都将打开和关闭文件。

if you want to print data in the console, then echo ...>con 如果要在控制台中打印数据,则echo ...>con

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

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