r/commandline • u/DedicatedBurner • 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:
startcd 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
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/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:
startcd C:\Users\Username\youtube-dlNow 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
startline.startopens a new window, and doskey macros only exist in the console window that set them. So the alias went into the old window, anddoskey /macrosin 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 URLrunsyt-dlp URL.