双击时将文件名传递给Windows批处理(.bat)脚本,以便它将以八度运行 [英] Pass filename to windows batch (.bat) script when double clicking so that it will run in octave

查看:106
本文介绍了双击时将文件名传递给Windows批处理(.bat)脚本,以便它将以八度运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用批处理脚本的新手,并且对八度有一定的经验.我使用倍频程函数检查了很多数据文件,并且尝试设置它们,以便双击具有自定义扩展名的文件直接打开倍频程函数.想想当我双击该文本文件时,它会在记事本中打开."

I'm new in using batch scripts, and moderately experienced with octave. I have a lot of data files I examine with octave functions and I am trying to set up so that I can double click on files with a custom extension to directly open octave functions. Think "when I double click on this text file, it opens in notepad."

为此,我编写了一个非常基本的.bat文件,并关联了.data文件以使用此.bat文件打开. .bat文件如下所示:

To do this I've written a very basic .bat file and I've associated my .data files to open using this .bat file. The .bat file looks like this:

C:\Octave\Octave-4.2.1\octave.vbs --no-gui --persist --eval myOctaveFunction.m
pause

我已经使用"myOctaveFunction"中的硬编码文件名对其进行了测试.但是,当我双击数据文件时,我实际上想将数据文件名传递给myOctaveFunction.我该怎么做呢?而且,批处理脚本甚至是正确的方法吗?

I've tested it with a hard coded filename inside "myOctaveFunction." but instead i'd like to actually pass the data file name to myOctaveFunction when I double click on the data file. How do I do this? And, are batch scripts even the right way to do this?

感谢您的帮助.

推荐答案

尝试此批处理文件,它将回显一些特定的项目:

Try this batch file, which will echo a few specific items:

@echo off
echo My directory %cd%
echo Batchfile Name %0
echo File to run %1
pause  

因此%1参数将为您提供文件名本身.

So %1 parameter will provide you with the filename itself.

您也可以像这样使用它.

You can also use it like this.

@echo off
echo My directory %cd%
echo Batchfile Name %~dpnx0
echo file to run %~dpnx1
pause

简而言之,如果您按照我认为的方式运行,这应该可以工作.

So in Short, this should work if you are running this the way I am thinking you do.

C:\Octave\Octave-4.2.1\octave.vbs --no-gui --persist --eval myOctaveFunction('%1')
pause

这篇关于双击时将文件名传递给Windows批处理(.bat)脚本,以便它将以八度运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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