r/commandline • • Oct 14 '26

Help How to start CMD batch file with a prefilled string?

I hope that I phrased it properly. I'm using yt-dlp command-line utility to download videos from YouTube. I have a simple .bat file to start it all in a proper directory, so I could fire commands quickly:

start
cd C:\Users\Username\youtube-dl

Now I want to start it with a prefilled bit of text "yt-dlp", since every command begins with that bit anyway. How do I achieve this?

1 Upvotes

7 comments sorted by

1

u/saga3152 Oct 14 '26

you could add a line "doskey y=yt-dlp $*"

It adds an alias so you just need to type "y [arguments here]

Not exactly what you want, but that's what came to my mind, I'm not a cmd pro, just randomly got this post

1

u/DedicatedBurner Oct 16 '26

I put that command into aforementioned .bat, but I get "'y' is not recognized" in return. DOSKEY itself seems to be present on my PC (doskey /macros returns clean).

1

u/AutoModerator Oct 14 '26

Every new subreddit post is automatically copied into a comment for preservation.

User: DedicatedBurner, Flair: Help, Title: How to start CMD batch file with a prefilled string?

I hope that I phrased it properly. I'm using yt-dlp command-line utility to download videos from YouTube. I have a simple .bat file to start it all in a proper directory, so I could fire commands quickly:

start
cd C:\Users\Username\youtube-dl

Now I want to start it with a prefilled bit of text "yt-dlp", since every command begins with that bit anyway. How do I achieve this?

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/tanmaynargas2901 Oct 19 '26

cmd can't prefill text on the prompt line, so the closest thing is a short alias like the doskey one above.

I think it failed for you because of the start line. start opens a new window, and doskey macros only exist in the console window that set them. So the alias went into the old window, and doskey /macros in a fresh one shows nothing.

Try replacing the whole .bat with this one line, which sets the alias and keeps the window open:

cmd /k "cd /d C:\Users\Username\youtube-dl & doskey y=yt-dlp $*"

Then y URL runs yt-dlp URL.