Windows批处理文件循环遍历目录处理文件? [英] Windows Batch File Looping Through Directories to Process Files?

查看:2315
本文介绍了Windows批处理文件循环遍历目录处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我是一个PHP程序员,不幸的是,对于原因,我不会宣布简便起见,我需要写/使用处理一些图像给我一个批处理文件。

Okay, I am a PHP programmer and unfortunately, for reasons I will not announce for brevity, I need to write/use a batch file that processes some imagery for me.

我有一个完整的嵌套的文件夹的文件夹,里面的每一个嵌套的文件夹的是多了一个包含若干TIF图片文件夹,图像数量每个文件夹中会有所不同。我也有一个批处理文件,让我们把它叫做ProcessImages.bat为Windows,你可以滴这些TIF文件(或明显调用时蝙蝠在命令行列表中指定它们);它所创建基于一个EXE文件,我有我的所有影像处理新文件夹。

I have one folder full of nested folders, inside each of these nested folders is one more folder that contains a number of TIF images, the number of images vary in each folder. I also have a batch file, lets call it ProcessImages.bat for Windows that you can "drop" these TIF files on (or obviously specify them in a command line list when invoking the bat); upon which it creates a new folder with all my images process based on an EXE that I have.

的好处是,由于bat文件使用从你砸到它的文件夹的路径,我可以选择一个文件夹的所有TIFs并把它做处理......但我继续手动做到这一点的TIFs我有我发现的300左右的文件夹,它停滞不前我的系统下如此令人难以置信的,如果我只能处理这些一次(没有做手工),那就太好了。

The good thing is that because the bat file uses the path from the folders you "drop" onto it, I can select all the TIFs of one folder and drop it to do the processing... but as I continue to manually do this for the 300 or so folders of TIFs I have I find it bogs my system down so unbelievably and if I could only process these one at a time (without manually doing it) it would be wonderful.

所有这一切说......可能有人点我在正确的方向(为Windows bat文件业余)的一种方法,我可以写一个Windows蝙蝠脚本,我可以从目录中调用,并将它遍历通过所有的包含在该目录内的目录...并在同一时间运行在每一组图片之一我处理的批处理文件?

All that said... could someone point me in the right direction (for a Windows bat file AMATEUR) in a way I can write a Windows bat script that I can call from inside a directory and have it traverse through ALL the directories contained inside that directory... and run my processing batch file on each set of images one at a time?

在此先感谢!

泰勒

推荐答案

您可以编写一个批处理递归算法,让你的你在每一个嵌套的子目录做精确控制:

You may write a recursive algorithm in Batch that gives you exact control of what you do in every nested subdirectory:

@echo off
call :treeProcess
goto :eof

:treeProcess
rem Do whatever you want here over the files of this subdir, for example:
for %%f in (*.tif) do echo %%f
for /D %%d in (*) do (
    cd %%d
    call :treeProcess
    cd ..
)
exit /b

这篇关于Windows批处理文件循环遍历目录处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆