通过串联变量不起作用而修改的文件路径

发布于 2025-01-23 11:19:11 字数 645 浏览 2 评论 0原文

我正在尝试做这项工作。请帮忙。

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 "${3}" -ss $1 -to $2 -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在不使用\时给出错误。

I'm trying to make this work. Please help.

folder="Test\ Folder"
path="/Volumes/Macintosh\ HD/Users/Shared/${folder}"
echo "$path"
if [ -d "$path" ]; then
echo "Yes"; else echo "No"
fi

This is the original script I'm working on.

echo in point
read inp
echo out point
read op
echo path
read ffolder

fName=`echo "$ffolder" | cut -d'/' -f1`

makejpgs () {
        ffmpeg -y -i "${3}" -ss $1 -to $2 -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 giving error when not using \.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

以歌曲疗慰 2025-01-30 11:19:11

如果您有一个值“引号之间”,则您需要不是需要逃脱\ spaces。因此,将每个\更改为

If you have a value "between quotes", then you do not need to escape\ spaces. So, change each \ into just .

如梦亦如幻 2025-01-30 11:19:11

您可以逃脱输入中的特殊字符。

echo path
read ffolder
ffolder=$(echo $ffolder | sed 's/[`~!@#$%^&*() -_=+{}\|;:",<.>/?'"'"']/\\&/g')

的输入上,我的桌面它将返回我的\ desktop,同样是[我的文件夹]它将返回\ [我的\文件夹\]

You can escape special characters in your input.

echo path
read ffolder
ffolder=$(echo $ffolder | sed 's/[`~!@#$%^&*() -_=+{}\|;:",<.>/?'"'"']/\\&/g')

On input of my desktop it will return my\ desktop and similarly for [my folder] it will return \[my\ folder\].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文