2011-02-11 2 views

답변

0

파일 이름과 관련된 정보를 제공하지 않았습니다.

많은 파일을 가져 와서 대문자에서 소문자로 변환하려고한다고 가정하면 다음과 같이 할 수 있습니다.

그런 다음 find 명령을 사용하여 파일의 디렉토리 트리 또는 파일의 부분 집합으로이 스크립트를 사용할 수


#!/bin/bash 

# this script takes one argument, a filename. If the file doesn't exist, we die. 
# to accomodate files with spaces in the name, we'll grab $* as the filename. 

filename="$*" 

lowername=$(echo "$filename" | tr [A-Z] [a-z]) 

if [ ! -f $filename ]; then 
echo "File: $filename: file not found!" 
exit 1 
fi 

printf "%-70s" "Renaming $filename to $lowername: " 
st=$(mv "$filename" "$lowername" 2>&1) 
if (($? == 0)); then 
printf "%-8s\n" "[ ok ]" 
else 
printf "%-8s\n" "[ err ]" 
fi 

rename.sh.

find /some/directory/with/files -type f -name \*JPG -exec bash rename.sh {} \; 

는 이제 'TR'인수를 수정하고 파일 이름을 변경 얻을하는 이름 바꾸기 규칙을 사용자 정의하는 인수를 '발견', 그리고 그들은 어떻게 이름을 바꿀 수 있습니다.

관련 문제