如何处理for循环批处理目录中的所有文件?

时间:2020-11-26 02:23:54

I want to do the command jhove -m PDF-hul -h xml -o C:\Users\N\test.xml %%a for each file in the directory through for loop. The problem is that only one last file from the directory will be processed. This is my code:

我想通过for循环为目录中的每个文件执行命令jhove -m PDF-hul -h xml -o C:\ Users \ N \ test.xml %% a。问题是只处理目录中的最后一个文件。这是我的代码:

@echo off

for /f %%a in ('dir /b /s C:\Users\N\test\') do (

jhove -m PDF-hul -h xml -o C:\Users\N\test.xml %%a

)


pause

1 个解决方案

#1


-1  

Your loop is setup to loop through a text file by using the /f option. I think if you drop that option, it should properly access each file during that loop.

您的循环设置为使用/ f选项循环遍历文本文件。我想如果你删除该选项,它应该在该循环期间正确访问每个文件。

See below for change:

见下面的变化:

for %%a in ('dir /b /s C:\Users\N\test\') do (

jhove -m PDF-hul -h xml -o C:\Users\N\test.xml %%a

)

#1


-1  

Your loop is setup to loop through a text file by using the /f option. I think if you drop that option, it should properly access each file during that loop.

您的循环设置为使用/ f选项循环遍历文本文件。我想如果你删除该选项,它应该在该循环期间正确访问每个文件。

See below for change:

见下面的变化:

for %%a in ('dir /b /s C:\Users\N\test\') do (

jhove -m PDF-hul -h xml -o C:\Users\N\test.xml %%a

)