0

我需要 3 个不同的批处理文件来完成 3 个不同的任务:

- 记录 HldsUpdateTool.exe 控制台的输出,到目前为止我没有看到发生了什么,但我管理了这个:

@echo off
echo Updating...
call :Logit>>log.txt 2>&1
exit /b 0
:Logit
hldsupdatetool.exe -command update -game "Counter-Strike Source" -dir "Source 2007 Dedicated Server" -verify_all -retry
start notepad log.txt

-清理此日志以获取文件和文件夹列表;日志将如下所示:

Checking bootstrapper version ...
Updating Installation
Determining which depot(s) to install/update...
5 depot(s) will be installed/updated
  0:30 Checking local files and building download list for depot 242 'Counter-Strike Source Shared' version 126
  0:30     Connecting content server session for version 126
  0:31     [80.239.194.146:27030] Connecting...
  0:31     [80.239.194.146:27030] Connection established; handshaking...
  0:31     [80.239.194.146:27030] Sending login message...
  0:31     Fetching version 126 manifest
  0:41     Reading version 126 checksum table
  0:54     Calculating download size and verifying checksums
  0:54         Checking...: /
  0:54         Checking...: cstrike
  0:54         Checking...: cstrike\bin
  0:54         Checking...: cstrike\cfg
  0:54         Checking...: cstrike\classes
  0:54         Checking...: cstrike\maps
  0:54         Checking...: cstrike\maps\graphs
  0:54         Checking...: cstrike\maps\soundcache
  0:57         Checking...: cstrike\materials
  0:57         Checking...: cstrike\materials\brick
  0:57         Checking...: cstrike\materials\buildings
  0:57         Checking...: cstrike\materials\carpet
  0:57         Checking...: cstrike\materials\composite
  0:57         Checking...: cstrike\materials\concrete
  0:58         Checking...: cstrike\materials\console
etc... later on files do not have extensions!

-从未列出的任何文件或文件夹中清除服务器文件夹!

我确实搜索了2天,但这是我自己可以去的地方......

4

2 回答 2

1

您可以将其缩短为

@echo off
hldsupdatetool.exe -command update -game "Counter-Strike Source" -dir "Source 2007 Dedicated Server" -verify_all -retry >Log.txt
start notepad Log.txt

文件未显示扩展名的问题将归结为您正在运行的程序,批处理所做的只是调用 exe 并重定向输出。

于 2012-07-19T13:21:50.187 回答
0

首先,我绝对是批处理的新手 :) 至于第二个问题:-清理此日志以获取文件和文件夹列表;日志将如下所示:

for /f "tokens=3" %G in ('findstr /i /c:"checking..." log.txt')do echo %G>>_.log

愿它对你有用。

更新: 我下载你的 log.txt 并立即测试,这是结果(文件名 _.log):

/
cstrike
cstrike\bin
cstrike\cfg
cstrike\classes
cstrike\maps
cstrike\maps\graphs
cstrike\maps\soundcache
cstrike\materials
cstrike\materials\brick
cstrike\materials\buildings
cstrike\materials\carpet
cstrike\materials\composite
cstrike\materials\concrete
cstrike\materials\console
cstrike\materials\cs_assault
cstrike\materials\cs_havana
cstrike\materials\cs_italy
cstrike\materials\cstrike
cstrike\materials\de_aztec
cstrike\materials\de_cbble
cstrike\materials\de_chateau
cstrike\materials\de_dust
cstrike\materials\de_nuke
cstrike\materials\de_piranesi
cstrike\materials\de_prodigy
cstrike\materials\de_tides
cstrike\materials\de_train
cstrike\materials\decals
cstrike\materials\decals\concrete
cstrike\materials\decals\metal
cstrike\materials\decals\wood
...

也许我误解了你的意思?

再次更新

至于第三个问题

@echo off
set /p origin=Where is the original folder?(Type absoulute path directly.)
echo origin: %origin%
set /p destin=Where can i put file temporarily(Type absoulute path directly.)
echo destination :%destin%


for /f %%G in (_.log) do (
if "%%G"=="/" (
    echo.
) else ( 
    xcopy %origin%\%%G %destin%\%%G /H /K /R /E /D /I /Y 
))

rm -rf %origin%
set /p origin=What is the name of original folder?(Type name)
rename %destin% %origin%

愿它帮助你!

第三次更新:)

因为第一版可能对你来说有点混乱。对不起,我缺乏能力 ti 代码很好。

@echo off
setlocal enabledelayedexpansion
set MAXNUM=100

set /p origin=Where is the original folder?(Type absoulute path directly.)
echo origin: %origin%
set backup_origin=%origin%

for /L %%H in (1,1,%MAXNUM%) do (
for /F "delims=\" %%G in ("!origin!") do (
set name=%%G
set origin=!origin:%%G\=!
))
set father=!backup_origin:\%name%=!

xcopy !father!\!name! !father!\backup_!name! /H /K /R /E /D /I /Y
::copy files
rm -rf !father!\!name!
::delete origin
rename !father!\backup_!name! !name!
::rename the new folder using the old's name

如果你的文件是这样的格式C:\template\example\cstrike\materials\brick,你应该只输入c:\template\example,其中包括\hl2 \cstrike等等。我在 Win7 上工作,你可能不会。所以我建议你将我的批处理文件调整到你的操作系统。在运行之前,
检查你有xcopy,,为你工作。Trmrename

于 2012-07-19T16:07:58.907 回答