본문 바로가기

wif LiNoUz/SERVER

배치 예제

dir /b 결과를 AAA변수에 input

 

--===============================================

for /f %a in ('dir /b') do    set AAA=%a

echo %AAA%

--===============================================

 

tokens=1 delims

tokens 써보자 first  of directory list 뽑는것

 

 

--===============================================

::CMD.EXE batch script to display last  2 lines from a txt file

 

@echo OFF

:: Get the number of lines in the file
set LINES=0
for /f "delims==" %%I in (data.txt) do (
    set /a LINES=LINES+1
)

:: Print the last 10 lines (suggestion to use more courtsey of dmityugov)
set /a LINES=LINES-2
more +%LINES% < data.txt

 

--===============================================

:: 더 간단한 예제

 

@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (c:\tmp\foo.txt) do (
set var4=!var3!
set var3=!var2!
set var2=!var1!
set var1=!var!
set var=%%a
)
echo !var4!
echo !var3!
echo !var2!
echo !var1!
echo !var!

'wif LiNoUz > SERVER' 카테고리의 다른 글

윈도우 2008 환경설정  (0) 2014.08.12
성능모니터링  (0) 2014.05.14
배치파일 명령어 모음  (0) 2014.05.01
성능모니터링  (2) 2014.01.13
router add 다중 네트워크  (3) 2013.03.25