拖放文件到sh文件 [英] Dragging and Dropping a File onto a .sh file

查看:255
本文介绍了拖放文件到sh文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当不错的使用批次的知识量。我试图端口一个批处理脚本到的Mac / UNIX,但我的批处理文件有一个拖和下降的事情吧。经过无数谷歌搜索,我什么也没有上来。他们都说,你可以拖动和拖放到一个终端窗口 - 无 - 输入所需的脚本并不好。下面是批量的code我有:

I have a fairly good amount of knowledge with Batch. I'm trying to port a batch script over to Mac/UNIX, but my batch file has a drag-and-drop thing to it. Through countless Google searches, I have came up with nothing. They all say that you can drag-and-drop into a Terminal Window - not good for no-input-required scripts. Here is the code for Batch I have:

CD%USERPROFILE%

cd %USERPROFILE%

7za X%* -o%USERPROFILE%\\桌面\\温度

7za%1%USERPROFILE%\\桌面\\温度*

CD%USERPROFILE%\\桌面
命令rmdir / Q / S TEMP \\

不是特别担心7za命令(因为归档实用程序),CD%USERPROFILE%(因为终端开始在用户的配置文件),命令rmdir,CD,这样的,因为他们只是基本的文件命令。但我不知道code引用到文件掉线/打开使用.sh脚本。因此,如果有人知道,code,请告诉我。我知道这是一种-的一个简单的事情,但你无法知道每一个命令,尤其是不熟悉的编程语言的时候。先谢谢了。

Not particularly worried about 7za commands (because of Archive Utility),cd %USERPROFILE% (because Terminal starts in the user's profile), rmdir, cd, and such, as they are only basic file commands. But I don't know the code to reference to the file dropped/opened with the .sh script. So, if someone knows that code, please tell me. I know this is kind-of a simple thing, but you can't know every command, especially when dealing with unfamiliar programming languages. Thanks in advance.

推荐答案

我不知道的方式有原始脚本接受拖动和丢弃的文件,但也有多种选择把它包起来的东西其他接受拖动和下降,并且将文件传送到的脚本。 IMO最快的办法是在包装中的脚本的Automator应用程序。运行/Applications/Automator.app,选择应用程序作为新的项目类型,从拖动操作列表中(第二列)运行Shell脚本行动纳入工作流程(右列),设置它的通输入到作为参数,粘贴到shell脚本,然后保存应用程序。完成。

I don't know of a way to have the raw script accept drag-and-dropped files, but there are a number of options to wrap it in something else that accepts drag-and-drop, and passes the files to a script. IMO the quickest option is to wrap the script in an Automator application. Run /Applications/Automator.app, select Application as the type for your new project, drag the "Run Shell Script" action from the actions list (second column) into the workflow (right column), set its "Pass input" to "as arguments", paste in the shell script, then save the app. Done.

用于包装的shell脚本的其他选项包括:的AppleScript ,的Platypus DropScript

Other options for wrapping a shell script include: AppleScript, Platypus, and DropScript.

这篇关于拖放文件到sh文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆