
처음으로 Nautilus 스크립트를 작성하고 있지만 계속하는 방법을 잘 모르겠습니다. 폴더의 모든 MP4 파일을 삭제하려면 이 노틸러스 스크립트에 무엇을 추가해야 합니까?~ 후에FFMPEG가 MOV로의 변환을 완료합니까?
#!/bin/bash
echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | find '*.mp4'
for i in *.mp4; do ffmpeg -i "$i" -c:v copy -c:a pcm_s16le -ar 48000 -ac 2 "$(echo "$i"|cut -d\. -f1).mov";done
감사합니다! :)
답변1
파일을 제거하십시오 (강제 옵션을 활성화하는 것이 좋습니다) $i
.
#!/bin/bash
echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | find '*.mp4'
for i in *.mp4
do
ffmpeg -i "$i" -c:v copy -c:a pcm_s16le -ar 48000 -ac 2 "$(echo "$i"|cut -d\. -f1).mov"
rm -f "$i"
done
- 원하는 경우 개행 문자를 세미콜론
;
기호로 바꿀 수 있습니다.
또 다른 옵션은파일을 휴지통으로 옮기세요삭제하는 대신:
gvfs-trash "$i"
또한 다음과 같은 방법으로 스크립트를 개선할 수 있습니다.
#!/bin/bash -e
# Get the items selected in Nautilus as an array
IFS_BAK=$IFS
IFS=$'\t\n'
FILE_LIST=($NAUTILUS_SCRIPT_SELECTED_FILE_PATHS)
IFS=$IFS_BAK
# For each item in the array $FILE_LIST
for ((i=0; i<${#FILE_LIST[@]}; i++))
do
# Get the file extension
FILE_EXT="${FILE_LIST[$i]##*.}"
# If the item is a file and its extension is mp4
if [[ -f ${FILE_LIST[$i]} ]] && [[ $FILE_EXT == 'mp4' ]]
then
# Get the filename
FILE_NAME="${FILE_LIST[$i]%.*}"
# Compose the name of the new file
THE_NEW_FILE="${FILE_NAME}.mov"
# Do the conversion
ffmpeg -i "${FILE_LIST[$i]}" -c:v copy -c:a pcm_s16le -ar 48000 -ac 2 "$THE_NEW_FILE"
# Remove the item: rm -f "${FILE_LIST[$i]}"; or move it to the trash:
gvfs-trash "${FILE_LIST[$i]}"
# Output a message, note ##*/ will remove the path from the filename
notify-send "mp4 to mov" "${THE_NEW_FILE##*/} - was created\n${FILE_LIST[$i]##*/} - was moved to the Тrash"
fi
done
다음은 관련 질문 중 하나입니다.비디오와 자막을 병합한 후 기존 파일을 삭제하는 스크립트