2016-07-21 77 views
0

我需要將我的輸出讀爲文本文件。 這是三個文件。 (1)目前,我有作爲輸入文件 (2)目前,我有作爲一個輸出文件 (3)其實我需要什麼作爲了把獲取文本文件大小的批處理腳本

我有六個.ptp文件。它來自G代碼。我需要通過一行一行相同來獲得的每個文件的大小在數(3) 作爲一個例子: 「01.ptp」的大小是123290個字節

//(1) 
@ECHO OFF 

set "filename=*.ptp" 
set "filename1=*_MachTime.txt" 

for %%A in (%filename1%) do ( 
    for %%B in (%filename%) do (
     echo Size of "%%B" is %%~zB bytes >>shop1.txt 
     ) 
type %%A >>shop1.txt 
) 

exit​ 




//(2) 

Size of "01.ptp" is 123290 bytes 
Size of "02.ptp" is 7714 bytes 
Size of "03.ptp" is 43473 bytes 
Size of "04.ptp" is 41137 bytes 
Size of "05.ptp" is 45802 bytes 
Size of "06.ptp" is 75346 bytes 

======================================================================================= 
LAB12JT01-UG01              Time 26.92 MIN. 
O0010   ToolD5_FLAT    S 3000.00 F 300.00     Z -64.00 mm 
-------------------------------------------------------------------------------------- 

Size of "01.ptp" is 123290 bytes 
Size of "02.ptp" is 7714 bytes 
Size of "03.ptp" is 43473 bytes 
Size of "04.ptp" is 41137 bytes 
Size of "05.ptp" is 45802 bytes 
Size of "06.ptp" is 75346 bytes 

======================================================================================= 
LAB12JT01-UG02              Time 2.59 MIN. 
O0020   ToolD2X10_FLAT   S 7500.00 F 200.00     Z -57.20 mm 
-------------------------------------------------------------------------------------- 

Size of "01.ptp" is 123290 bytes 
Size of "02.ptp" is 7714 bytes 
Size of "03.ptp" is 43473 bytes 
Size of "04.ptp" is 41137 bytes 
Size of "05.ptp" is 45802 bytes 
Size of "06.ptp" is 75346 bytes 

======================================================================================= 
LAB12JT01-UG03              Time 8.30 MIN. 
O0030   ToolD1X4_FLAT    S 7500.00 F 100.00     Z -56.00 mm 
-------------------------------------------------------------------------------------- 

Size of "01.ptp" is 123290 bytes 
Size of "02.ptp" is 7714 bytes 
Size of "03.ptp" is 43473 bytes 
Size of "04.ptp" is 41137 bytes 
Size of "05.ptp" is 45802 bytes 
Size of "06.ptp" is 75346 bytes 

======================================================================================= 
LAB12JT01-UG04              Time 8.03 MIN. 
O0040   ToolD1X4_FLAT    S 7500.00 F 100.00     Z -56.00 mm 
-------------------------------------------------------------------------------------- 

Size of "01.ptp" is 123290 bytes 
Size of "02.ptp" is 7714 bytes 
Size of "03.ptp" is 43473 bytes 
Size of "04.ptp" is 41137 bytes 
Size of "05.ptp" is 45802 bytes 
Size of "06.ptp" is 75346 bytes 

======================================================================================= 
LAB12JT01-UG05              Time 7.10 MIN. 
O0050   ToolD1_BALL    S 7500.00 F 200.00     Z -50.27 mm 
-------------------------------------------------------------------------------------- 

Size of "01.ptp" is 123290 bytes 
Size of "02.ptp" is 7714 bytes 
Size of "03.ptp" is 43473 bytes 
Size of "04.ptp" is 41137 bytes 
Size of "05.ptp" is 45802 bytes 
Size of "06.ptp" is 75346 bytes 
​ 



//////(3) 
Size of "01.ptp" is 123290 bytes 
======================================================================================= 
LAB12JT01-UG01              Time 26.92 MIN. 
O0010   ToolD5_FLAT    S 3000.00 F 300.00     Z -64.00 mm 
-------------------------------------------------------------------------------------- 

Size of "02.ptp" is 7714 bytes 
======================================================================================= 
LAB12JT01-UG02              Time 2.59 MIN. 
O0020   ToolD2X10_FLAT   S 7500.00 F 200.00     Z -57.20 mm 
-------------------------------------------------------------------------------------- 


Size of "03.ptp" is 43473 bytes 
=================================================================================== 
LAB12JT01-UG03              Time 8.30 MIN. 
O0030   ToolD1X4_FLAT    S 7500.00 F 100.00     Z -56.00 mm 
-------------------------------------------------------------------------------------- 


Size of "04.ptp" is 41137 bytes 
======================================================================================= 
LAB12JT01-UG04              Time 8.03 MIN. 
O0040   ToolD1X4_FLAT    S 7500.00 F 100.00     Z -56.00 mm 
-------------------------------------------------------------------------------------- 


Size of "05.ptp" is 45802 bytes 
======================================================================================= 
LAB12JT01-UG05              Time 7.10 MIN. 
O0050   ToolD1_BALL    S 7500.00 F 200.00     Z -50.27 mm 
-------------------------------------------------------------------------------------- 


Size of "06.ptp" is 75346 bytes 
======================================================================================= 
LAB12JT01-UG06              Time 8.69 MIN. 
O0060   ToolD0.6_FLAT    S 7500.00 F 100.00     Z -51.60 mm 
-------------------------------------------------------------------------------------- 
​ 
+4

爲什麼標記爲'javascript'和'java'? –

+0

我很好,從Java和Java腳本的答案也 – Suba

+0

請重新格式化您的問題!看看它 - 是不是很混亂? – aschipfl

回答

0

只要定義一個全局計數器(COUNTER)和本地計數器(COUNTER2)。僅在兩個計數器匹配時纔打印尺寸。

@ECHO OFF 

set "filename=*.ptp" 
set "filename1=*_MachTime.txt" 
SETLOCAL ENABLEDELAYEDEXPANSION 
set COUNTER=0 

for %%A in (%filename1%) do (
    set COUNTER2=0 

    for %%B in (%filename%) do (
     rem if !COUNTER2!==!COUNTER! echo Size of "%%B" is %%~zB bytes >> shop1.txt 
     rem update with size in KB 
     set /A KBS=%%~zB/1024 
     if !COUNTER2!==!COUNTER! echo Size of "%%B" is !KBS! bytes >> shop1.txt 
     set /A COUNTER2=!COUNTER2!+1 
     ) 
    set /A COUNTER=!COUNTER!+1 
type %%A >> shop1.txt 
) 

不是很優雅,但嘿,這是批處理文件畢竟你期望什麼?

+0

謝謝,工作 – Suba

+0

有人可以幫我在上面的例子中通過kilobytes出來嗎?只需要將字節值改爲kilobyte – Suba

+0

'set/A KB = %% 〜zB/1024'。未經測試可能需要!KB!而不是%KB%在循環內打印 –