简体   繁体   English

使用预加载命令打开命令提示符的快捷方式

[英]Shortcut to open command prompt with preloaded command

I use FFMPEG to convert MP4s to WEBMs.我使用FFMPEG将 MP4 转换为 WEBM。 This involves me constantly copying over my preferred script into the command prompt every single time.这涉及我每次都不断地将我喜欢的脚本复制到命令提示符中。 Is there a way to open a commant prompt with a certain command already set up and ready to go without executing the commmand immediately so that it is still editable?有没有办法打开一个命令提示符,其中某个命令已经设置好并准备好了,而无需立即执行命令,以便它仍然可编辑? Many times I need to change parameters of the script to match the specific file I will be converting...so simply having a pre-loaded script that runs by itself doesn't make sense.很多时候我需要更改脚本的参数以匹配我将要转换的特定文件......所以简单地拥有一个自行运行的预加载脚本是没有意义的。

Tried making a CMD shortcut but couldn't find a way to do this without automatically running the command.尝试制作 CMD 快捷方式,但找不到不自动运行该命令的方法。 Tried making a batch file, got the script to copy in, but it wasn't editable.尝试制作批处理文件,将脚本复制进来,但无法编辑。

Here is the FFMPEG script I use: ffmpeg -i "in.mp4" -b:v 3000k -b:a 128k -threads 6 out.webm这是我使用的FFMPEG脚本: ffmpeg -i "in.mp4" -b:v 3000k -b:a 128k -threads 6 out.webm

open notepad, save the content below into it and save it as my_ffmpeg_script.cmd and simply double click it:打开记事本,将下面的内容保存到其中并保存为my_ffmpeg_script.cmd并双击它:

@echo off
:start
cls
set /p "input=Filename to convert?: "
set /p "output=Output filename?: "
set /p "rate1=a rate? (i.e 3000): "
set /p "rate2=b rate? (i.e 128): "
set /p "threads=Threads? (i.e 6): "

ffmpeg -i "%input%" -b:v %rate1%k -b:a %rate2%k -threads %threads% %output%
set /p "next=Would you like to convert another?(y/n): "
if /i "%next%"=="n" exit
if /i "%next%"=="y" goto :start

It will prompt you for your input, output, rates and threads, then do the conversion and ask if you want to do another file, if yes, start prompt again, if no, it will exit the script.它将提示您输入、输出、速率和线程,然后进行转换并询问您是否要执行另一个文件,如果是,则再次启动提示,如果不是,它将退出脚本。

Obviously you can set some of the values as default values in the line and not prompt for them, if they will never change.显然,您可以将某些值设置为行中的默认值,如果它们永远不会改变,则不提示它们。 This is simply to show you how to do something like this.这只是为了向您展示如何做这样的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM