Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Sure you can. Sort-of at least:

a. Ask only for file extension.

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

b. Ask file Name and extension (from comments.)

@echo off    
set /p name=File name?
set /p extension=What file extension?
copy NUL %name%.%extension%
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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