Adding commands to the command line
April 24, 2010 3:45 AM   Subscribe

How do I create a shortcut to a command prompt window that will start a programme, with specific variables within the command prompt window?

I'm using ffmpeg to convert some .flv files to .mp4 files. The command I'm using is:

ffmpeg.exe -vcodec copy -acodec copy -i INPUT.flv OUTPUT.mp4

I have a shortcut (.lnk file) in the Start Menu that will load a command prompt window, which is this:

Target: C:\WINDOWS\system32\cmd.exe /k ffmpeg.exe
Start in: C:\Program Files\ffmpeg\bin

Everything works great, apart from the fact that I have to type the whole command into the command prompt window every time. I want a shortcut that will load the command prompt window (like it already does) with the relevant command already inputted, so that when the window loads, it looks like this:

C:\Program Files\ffmpeg\bin>ffmpeg.exe -vcodec copy -acodec copy -i

This is on XP.
posted by Solomon to Computers & Internet (7 answers total)
 
Does this work? (I don't have a Windows box to test with)

Target: C:\WINDOWS\system32\cmd.exe /k ffmpeg.exe -vcodec copy -acodec copy -i INPUT.flv OUTPUT.mp4
posted by mohrr at 4:30 AM on April 24, 2010


Nevermind, reread the question. I don't know.
posted by mohrr at 4:30 AM on April 24, 2010


Why do you have to launch a command prompt. Won't a batch ( .bat ) file do this for you?
posted by kaizen at 4:34 AM on April 24, 2010


"In DOS, OS/2, and Microsoft Windows, a batch file is a text file containing a series of commands intended to be executed by the command interpreter. When a batch file is run, the shell program (usually COMMAND.COM or cmd.exe) reads the file and executes its commands, normally line-by-line." No?
posted by kaizen at 4:35 AM on April 24, 2010


There's a better way to handle this, using the command line and variables:

Put the following into a new .bat file

SET /P INPUT=Type your input filename
SET /P OUTPUT=Type your output filename
ffmpeg.exe -vcodec copy -acodec copy -i %INPUT%.flv %OUTPUT%.mp4

So when you double click that batch file, just type in the name of the .flv file (and don't put the .flv extension on it), hit enter, enter the output file name (again, no extension), hit enter, and ffmpeg should take off.
posted by deezil at 4:52 AM on April 24, 2010 [1 favorite]


Or you could make a batch file (similar to deezil's) that you associate with the flv extension.


set INPUT=%~f1

set OUTPUT=%~d1%~p1%~n1.mp4

ffmpeg.exe -vcodec copy -acodec copy -i "%INPUT%" "%OUTPUT%"


Then all you have to do is right click the file and "open with" your batch file. The fancy tildes in INPUT mean the fully qualified path name for the input file, and in OUTPUT mean the drive letter, the path and the filename without the extension.

This worked for me in a similar batch file I made using vlc. Vlc didn't work, but the batch file worked.
posted by gjc at 6:51 AM on April 24, 2010


I like gjc's solution as good as mine, so consider me endorsing that as well. In mine, if you wanted the .FLV and the .MP4 to have the same name, you could get rid of the second SET line, and replace %OUTPUT% in the third line with %INPUT%.
posted by deezil at 1:10 PM on April 26, 2010


« Older What are the chances of buying...   |  What are good examples of the ... Newer »
This thread is closed to new comments.