skip to Main Content

Hello Stack Overflow community,

I’m currently working on a React project and I need to create files with different extensions, specifically with extensions like .js and .ts. I’m wondering if there’s a straightforward way to achieve this with CMD?

I expected the code to successfully create a file with the specified extension, such as .js or .ts.

3

Answers


  1. You can use the echo command in combination with the > operator to create files with different extensions in the Windows command line. Here’s an example:

    echo > YourFileName.js
    
    Login or Signup to reply.
  2. In CMD, you can create empty files using the echo command with an empty string and then redirect the output to a file. Here’s how you can create empty files with different extensions in CMD:

    To create an empty JavaScript (.js) file:

    echo. > yourFileName.js
    

    To create an empty TypeScript (.ts) file:

    echo. > yourFileName.ts
    

    Here’s another way to create empty files with different extensions in PowerShell:

    To create an empty JavaScript (.js) file:

    New-Item -ItemType File -Path ".yourFileName.js"
    

    To create an empty TypeScript (.ts) file:

    New-Item -ItemType File -Path ".yourFileName.ts"
    
    Login or Signup to reply.
  3. You can create the .js and .ts files

    # Create a JavaScript file
    echo. > myfile.js
    
    # Create a TypeScript file
    echo. > myfile.ts
    

    And you can create the file with content like this

    # Create a JavaScript file with content
    echo console.log('Hello, JavaScript!') > myfile.js
    
    # Create a TypeScript file with content
    echo console.log('Hello, TypeScript!') > myfile.ts
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search