..png)
1.JPG, 2.JPG, ..., 12.JPG 파일이 있는 폴더가 있습니다.
모든 파일을 한번에 처리하는 표현이 있나요? JHead 명령을 사용하고 싶은데 일반적인 해결 방법이 있는 것 같습니다.
감사합니다!
답변1
필요한 처리가 1.JPG의 이름을 MyPicture1-320x480.jpg로, 2.JPG의 이름을 MyPicture2-320x480.jpg로 바꾸는 것과 같은 것이라면 Bash 쉘을 사용하는 경우 다음을 포함하는 디렉토리로 변경할 수 있습니다. 파일을 작성하고 다음과 같은 것을 사용하십시오.
i=0; for n in *.JPG; do mv "${n}" "MyPicture${n/.JPG/-320x480.jpg}"; i=$((i+1)); done; echo "Processed ${i} files."
(위의 내용은 모두 하나의 명령줄에 입력할 수 있습니다.)
또는 스크립트에 넣으려면 여러 줄로 읽고 이해하는 것이 더 쉬울 것입니다.
# reset counter variable if you want to count the number of files processed
i=0
# loop for all files in current working directory that end with ".JPG"
for n in *.JPG
do
# rename (move) each file from the original name (${n} is generally safer than $n)
# to a new name with some text before the original name and then with the end of
# the original name (".JPG") replaced with a new ending
mv "${n}" "MyPicture${n/.JPG/-320x480.jpg}"
# increment the counter variable
i=$((i+1))
done
# display the number of files processed.
echo "Processed ${i} files."
원하는 처리가 이와 다른 경우 질문을 편집하여 자세한 내용을 제공해야 할 수도 있습니다.