我创建了一个Nautilus Action
脚本来使用recode
应用程序更改文件编码。
我的操作是:
[Desktop Entry]
Type=Action
ToolbarLabel[en_US]=Convert Encoding From Windows-12
ToolbarLabel[en]=Convert Encoding From Windows-12
ToolbarLabel[C]=Convert Encoding From Windows-12
Tooltip[en_US]=Converts file content encoding from Windows-1256 and saves as UTF-8
Tooltip[en]=Converts file content encoding from Windows-1256 and saves as UTF-8
Tooltip[C]=Converts file content encoding from Windows-1256 and saves as UTF-8
Name[en_US]=Convert Encoding From Windows-1256
Name[en]=Convert Encoding From Windows-1256
Name[C]=Convert Encoding From Windows-1256
Profiles=profile-zero;
[X-Action-Profile profile-zero]
SelectionCount==1
MimeTypes=all/allfiles;
Matchcase=false
Basenames=*.srt;
Exec=recode windows-1256 "%F"
Name[en_US]=Default profile
Name[en]=Default profile
Name[C]=Default profile
ExecutionMode=DisplayOutput
代码运行一段时间后就失败了!
当我设置操作时,ExecutionMode
它DisplayOutput
显示以下内容:
Run command:
/bin/sh -c 'recode windows-1256 "'\''/home/ariyan/a.srt'\''"'
Standard output:
Standard error:
recode: fopen ('/home/ariyan/a.srt'): No such file or directory
它找不到文件!(当我在终端窗口中运行相同的命令时,它可以工作)
问题是什么?
为什么sh
找不到文件?
谢谢
答案1
问题出在命令中的引号!
使用recode windows-1256 %F
而不是recode windows-1256 "%F"
解决了问题!