I need a .cmd file that creates a new type of file when I click it. Is this possible? For example: Click .cmd file CMD pops up asking what file do I want to create...(eg: .css, .html) Then creates the file on the desktop. How would I do this? Or is this even possible on Windows?

link|improve this question

29% accept rate
feedback

1 Answer

up vote 1 down vote accepted

Sure you can. Sort of, at least.

@echo off
set /p extension=What file extension?
copy NUL "%UserProfile%\Desktop\New %extension% file.%extension"

for example.

link|improve this answer
Almost, but it becomes New File .extension instead? – Omnix Sep 16 '10 at 4:10
I fixed it, I took out the last 2 parts file.%extension%. Is there a way, where it asks me to name the file, then the extension? – Omnix Sep 16 '10 at 4:16
This is cool, nvm I got it!!! Thanks for helping! – Omnix Sep 16 '10 at 4:26
@Kawohi: Well, I was intending it so you can say "css" and it creates a file "New css file.css" And yes, you can also ask for the name, you just need another set /p name=File name? and then use copy NUL %name%.%extension% (or without the dot, if you prefer giving extensions with it). – Joey Sep 16 '10 at 10:05
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.