开发者

recursively run a command and check to see if it exists

开发者 https://www.devze.com 2023-02-05 14:05 出处:网络
On a Windows Env, I\'m trying to find a way to recursively check all files in a dirtree to see if they filename/size match a list of files in another dir, if they do exist in the dir, then it runs a c

On a Windows Env, I'm trying to find a way to recursively check all files in a dirtree to see if they filename/size match a list of files in another dir, if they do exist in the dir, then it runs a command on the file found

Psudocode:

Loop{
If(RecursivelyFindFiles() = FileInFileListingInResources()) {

DoCommand(cmd1 -开发者_JAVA百科D -R -N %FoundFile C:\resources\%Filename)

}

}

I know what i want, just dont know how to do it on a Windows Env


@echo off
for /r %root% %%f in (*.*) do if exist ..\folder\%%~nxf call :furthertests %%f folder\%%~nxf
goto :eof

:furthertests
echo %1 found
if not "%~z1"=="%~z2" goto :eof
echo file sizes match (%~z1 bytes)
@rem Do your stuff with %1 here
@rem ...

Assumes %root% is start of search tree, and ..\folder\ contains the prototype files.


here is a start !

@echo off
rem %1 First folder
rem %2 Other folder to compare
FOR /R %1 IN (*.*) DO echo %%G
echo Done!

Instead of the echo %%G, you can call fc %%G ABC which is a filecompare exe. But I don't know how to format ABC to be the Path to folder 2 (%2) + base filename of %%G.
After, a if test to the result of fc and you can call your processing.

I'm sorry, I admit I must stop here !

0

精彩评论

暂无评论...
验证码 换一张
取 消