'대문자변환'에 해당되는 글 1건

  1. 2009.06.27 linux &unix 대문자 소문자 변환 shell script 입니다. 3
IT2009. 6. 27. 19:59
반응형
linux &unix 대문자 소문자 변환 shell script 입니다.

#!/bin/csh
########################################################
#
# << Filename Case Conversion Script >>
#
########################################################
#
# 설명 : 현재 디렉토리에 있는 화일의 대*소문자 이름을
# 일괄적으로 바꾸어줍니다. 홈페이지 문서를 계
# 정상에 FTP를 이용하여 올리게 되면 간혹가다
# 화일이름들이 대문자로 바뀌는 경우가 있는데
# 이 스크립트를 이용하게 되면 한번에 쉽게 소
# 문자로 바꿀수가 있습니다. 유용하게 활용을
# http://jofw.tistory.com
#
########################################################
#
# argument count check
# if ( $# != 2 ) goto error
#
# parse option
#
########################################################

# renamed file number
set count = 0

echo " "
echo "*********** tocase script starting... ***********"
echo " "

switch ($1)
case "-l" :
foreach file ( * )
# 입력파일이름을 소문자로 저장합니다.
set file2 = `echo $file | tr A-Z a-z`

# 파일이 같은지를 검사합니다.
if ( $file != $file2) then
mv $file $file2
echo $file is renamed $file2
@ count++ # 변환된 파일개수를 카운트합니다.
endif
end
breaksw

case "-u" :
foreach file ( * )
# 입력파일이름을 대문자로 저장합니다.
set file2 = `echo $file | tr a-z A-Z`

# 파일이 같은지를 검사합니다.
if ( $file != $file2 ) then
mv $file $file2
echo $file is renamed $file2
@ count++
endif
end
breaksw

case "--help" :
case "-h" :
case "-\?" :
goto error

case "--version" :
case "-v" :
echo "tocase version is 0.0.1"
breaksw

default :
goto error
endsw

#######################################################
#
# Successfully Exit

echo " "
echo "-> Total $count files is renamed successfully!"
echo " "

#if ($1 == "-l") then
# echo "Total $count files is lowercased successfully!"
#else if ($1 == "-u") then
# echo "Total $count files is uppercased successfully!"
#endif

exit 0

#######################################################
# Display error message and quit
#

error:
cat << END_OF_ERROR
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Dear $USER, the usage of tocase is as follows: | "Wonder Boy" --\\->
[Usage] : tocase -[l|u] input_file |__________________________

tocase -l input_file means "input_file name is from uppercase to lowercase"
tocase -u input_file means "input_file name is from lowercase to uppercase"
---------------------------------------------------------------------------
END_OF_ERROR

#######################################################

# Unsuccessful exit!
exit 1
반응형

'IT' 카테고리의 다른 글

windows 7 usb dvd download tool  (4) 2009.11.18
sky n topstaired  (4) 2009.10.04
Debian 절전 모드 이후 Console 먹통 현상  (4) 2009.03.19
linux service 설명  (4) 2009.03.17
LINUX 우분투 에서 PCSX2 실행 화면이다.  (4) 2009.02.04
Posted by Dream Come True