DEV Community

shun
shun

Posted on

File and Directory Operations in Windows Commands

Creating and Removing

  • echo.: Create an empty file.
  C:\> echo. > newfile.txt
Enter fullscreen mode Exit fullscreen mode

mkdir: Create a new directory.

  C:\> mkdir new_directory
Enter fullscreen mode Exit fullscreen mode
  • del: Remove files.
  C:\> del file_to_remove.txt
Enter fullscreen mode Exit fullscreen mode
  • rmdir: Remove a directory (either empty or with contents).
  C:\> rmdir /s /q directory_to_remove
Enter fullscreen mode Exit fullscreen mode

Copying, Moving, and Renaming

  • copy: Copy files.
  C:\> copy source.txt destination.txt
Enter fullscreen mode Exit fullscreen mode
  • xcopy: Copy directories.
  C:\> xcopy /s /i source_directory destination_directory
Enter fullscreen mode Exit fullscreen mode
  • move: Move or rename files or directories.
  C:\> move oldname.txt newname.txt
Enter fullscreen mode Exit fullscreen mode

Listing and Navigating

  • dir: List directory contents.
  C:\> dir
Enter fullscreen mode Exit fullscreen mode
  • cd: Display or change the current directory.
  C:\> cd \path\to\directory
Enter fullscreen mode Exit fullscreen mode

File Content Viewing

  • type: Display the entire content of a file.
  C:\> type file.txt
Enter fullscreen mode Exit fullscreen mode
  • more: View file content with pagination.
  C:\> more file.txt
  (Note: Windows doesn't have direct equivalents to `head` and `tail` commands in its basic command prompt.)
Enter fullscreen mode Exit fullscreen mode

File and Directory Information

  • dir: Display detailed information about a file or directory.
  C:\> dir file.txt
  (Note: Windows doesn't have a direct equivalent to the `file` command in its basic command prompt.)
Enter fullscreen mode Exit fullscreen mode

Searching for Files

  • dir: Search for files in a directory.
  C:\> dir /s /b \path\to\search\*pattern*.txt
Enter fullscreen mode Exit fullscreen mode

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay