中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-23 13:56
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » How to write such a batch processing?
Printable Version  1,720 / 3
Floor1 表情 Posted 2004-12-15 00:00
初级用户 Posts 5 Credits 118
System: adv win2k
Goal to achieve: Synchronize files between two computers in the local area network. Then run the synchronized files.
There is a file xxx.exe in directory aaa on Computer A and it is shared.
Computer B can log in to Computer A (with username and password).
There is a file xxx.exe in directory BBB on Computer B.
Problem:
Now automatic login to Computer A has been achieved on Computer B and the shared directory is mapped as a drive letter R: on Computer B.
Now we want to perform copy if the file on Computer A is different from the file on local Computer B (just different dates are okay, and also copy if the file does not exist locally, both are xxx.exe). After copying, execute xxx.exe.
Now only a batch file is missing.
If there is a batch file, it can be combined with Windows scheduled tasks for full automation.
Which gentleman can write the batch file. Thanks in advance.
Can fc and comp be used! Please write the batch file. ------------
------------
Now it is achieved that the date of the file can be displayed using the statement for. That is, use for /f "skip=3" %a IN ('dir e:\a\xxx.exe' do @if exist %a echo %~ta
But how to compare. But I write these commands in the batch file and they are not correct. Who knows.
Always getting errors. But it is normal in the command line.
Depressed~~~
Floor2 表情 Posted 2004-12-16 00:00
初级用户 Posts 5 Credits 118
Keep up the good work. I finally succeeded.
Just why can't it be executed in the batch file.
It can be done in the command line. Why is that.
@echo off
if EXIST xxx.exe goto cmp
xcopy r:\aaa\xxx.exe
:cmp
for /f "skip=3" %%a IN ('dir r:\aaa\xxx.exe' do @if exist %%a set var1=%%~ta
for /f "skip=3" %%a IN ('dir xxx.exe' do @if exist %%a set var2=%%~ta
if %var1%==%var2% do goto end
copy r:\aaa\xxx.exe /yy
xxx.exe
:end
----------------
How can the if be used because there are spaces in var1.


Floor3 willsort Posted 2004-12-16 00:00
元老会员 Posts 1,512 Credits 4,432
Re: Expression:
  To solve the space problem of var, you can add quotes on both sides of var1 and var2, just like
if "%var1%"=="%var2%" do goto end
This method is not applicable to win9x/dos6.xx (under its environment, you need to first output to a file, then use fc+find to judge).
Also: The do in your statement seems redundant. Try changing it to the following form:
if "%var1%"=="%var2%" goto end
Floor4 表情 Posted 2004-12-17 00:00
初级用户 Posts 5 Credits 118
Thanks to the person above. I'm really stupid myself
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023