2010-11-27 13 views
0

確かにこれは明らかですが何らかの理由で、 :名前を変更します。誰かが私にここの問題が何であるか教えてもらえますか?これは、2つの他の質問に関連している - ここでLooking for a way to execute a batch file once a folder hits 10 filescopy and rename files of a certain extension via batch fileバッチファイルが2回実行されている理由を把握しようとしています

は、バッチファイル--->

rem Counting files... 
set /a count = 0 
for /f "tokens=*" %%P IN ('dir "H:\" /A /b') do (set /a count += 1) 



rem 5 or more files? 



if %count% GEQ 5 call :rename 



:rename 
SET count=1 
FOR /f "tokens=*" %%G IN ('dir /b *.jpg') DO (call :rename_next "%%G") 

goto:copy 

:rename_next 
ren "%1" %count%.jpg 

Pause 
set /a count+=1 

goto:eof 

:copy 
xcopy c:\photo\*.jpg c:\photo\files /Y 
Pause 
+0

が働いたとセンスを作ったこと、ありがとうございました。私は外出するためにgoto:eofを追加しました。 – samsam

答えて

0

この行です:

if %count% GEQ 5 call :rename 

:renameを呼んでいます。名前の変更が返された後、コードはこの後に続き、:renameとなります。

何が起こっているかを確認するには、このコードで置き換えます

echo before call 
if %count% GEQ 5 call :rename 
echo after call 
関連する問題