File and Directory Operations in Windows Commands
shun
Posted on August 12, 2023
Creating and Removing
-
echo.
: Create an empty file.
C:\> echo. > newfile.txt
mkdir: Create a new directory.
C:\> mkdir new_directory
-
del
: Remove files.
C:\> del file_to_remove.txt
-
rmdir
: Remove a directory (either empty or with contents).
C:\> rmdir /s /q directory_to_remove
Copying, Moving, and Renaming
-
copy
: Copy files.
C:\> copy source.txt destination.txt
-
xcopy
: Copy directories.
C:\> xcopy /s /i source_directory destination_directory
-
move
: Move or rename files or directories.
C:\> move oldname.txt newname.txt
Listing and Navigating
-
dir
: List directory contents.
C:\> dir
- cd: Display or change the current directory.
C:\> cd \path\to\directory
File Content Viewing
-
type
: Display the entire content of a file.
C:\> type file.txt
-
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.)
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.)
Searching for Files
-
dir
: Search for files in a directory.
C:\> dir /s /b \path\to\search\*pattern*.txt
💖 💪 🙅 🚩
shun
Posted on August 12, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.