通过连接变量修改的文件路径不起作用
File path that modified by concatenating variables not working
我正在努力完成这项工作。请帮忙。
folder="Test\ Folder"
path="/Volumes/Macintosh\ HD/Users/Shared/${folder}"
echo "$path"
if [ -d "$path" ]; then
echo "Yes"; else echo "No"
fi
这是我正在处理的原始脚本。
echo in point
read inp
echo out point
read op
echo path
read ffolder
fName=`echo "$ffolder" | cut -d'/' -f1`
makejpgs () {
ffmpeg -y -i "" -ss -to -vf fps=12 "$fName_%d.jpg"
}
path="/Volumes/PROJECTS/Main/${fName}"
files=$(find "$path" -type f -name "*story*")
echo "$files"
for i in $files; do
echo "$i"
makejpgs "$inp" "$op" "$i"
done
ffmpeg 在不使用 \
.
时出错
如果您有一个值 "between quotes"
,那么您 不需要 escape\ spaces
。因此,将每个 \
更改为
.
您可以在输入中转义特殊字符。
echo path
read ffolder
ffolder=$(echo $ffolder | sed 's/[`~!@#$%^&*() -_=+{}\|;:",<.>/?'"'"']/\&/g')
在 my desktop
的输入上它将 return my\ desktop
并且对于 [my folder]
类似地它将 return \[my\ folder\]
.
我正在努力完成这项工作。请帮忙。
folder="Test\ Folder"
path="/Volumes/Macintosh\ HD/Users/Shared/${folder}"
echo "$path"
if [ -d "$path" ]; then
echo "Yes"; else echo "No"
fi
这是我正在处理的原始脚本。
echo in point
read inp
echo out point
read op
echo path
read ffolder
fName=`echo "$ffolder" | cut -d'/' -f1`
makejpgs () {
ffmpeg -y -i "" -ss -to -vf fps=12 "$fName_%d.jpg"
}
path="/Volumes/PROJECTS/Main/${fName}"
files=$(find "$path" -type f -name "*story*")
echo "$files"
for i in $files; do
echo "$i"
makejpgs "$inp" "$op" "$i"
done
ffmpeg 在不使用 \
.
如果您有一个值 "between quotes"
,那么您 不需要 escape\ spaces
。因此,将每个 \
更改为
.
您可以在输入中转义特殊字符。
echo path
read ffolder
ffolder=$(echo $ffolder | sed 's/[`~!@#$%^&*() -_=+{}\|;:",<.>/?'"'"']/\&/g')
在 my desktop
的输入上它将 return my\ desktop
并且对于 [my folder]
类似地它将 return \[my\ folder\]
.