简体   繁体   English

转换文件并将它们放置在另一个目录中

[英]Convert files and place them in another directory

I am trying to edit a script I found online. 我正在尝试编辑在线找到的脚本。 The script is supposed to convert all files in a directory and place them in another directory (Using handbrake) but it only passes the first word of the file and not the subsequent words or the file extension 该脚本应该将所有文件转换为一个目录,然后将它们放置在另一个目录中(使用手刹),但是该脚本仅传递文件的第一个单词,而不传递后续的单词或文件扩展名

#!/bin/bash
SRC="/var/www/mediacenter/convert"
DEST="/var/www/mediacenter/converted"
DEST_EXT=mp4
HANDBRAKE_CLI=HandBrakeCLI
#PRESET = " -e x264 -E av_aac -q 22"

for FILE in "$SRC"/*
do
filename=$(echo $FILE | cut -f 1 -d '.')
extension="${filename##*.}"
filename="${filename%.*}"
echo $filename.$DEST_EXT
$HANDBRAKE_CLI -i "$FILE" -o $FILE.$DEST_EXT  $PRESET
done

The echo works and I have tried quoting it but can't find the right combination. 回声有效,我尝试引用它,但找不到正确的组合。

文件名包含空格时,需要添加双引号。

$HANDBRAKE_CLI -i "$FILE" -o "$FILE.$DEST_EXT" $PRESET

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM