# cd / Set-LocationChange folder
Syntax cd [path]
> cd C:\Users\Alice\DocumentsCMD Copy
Go to a folder
> cd ..CMD Copy
Go up one level
> cd /d D:\ProjectsCMD Copy
Switch to another drive and folder at once (CMD needs /d)
PS> Set-Location C:\WindowsPowerShell Copy
PowerShell's full name; cd also works
Tip Type a drive letter and a colon, such as D:, to switch drives in CMD.
# dir / Get-ChildItemList files and folders
Syntax dir [path] [options]
> dirCMD Copy
List the current folder
> dir /aCMD Copy
Include hidden files
> dir /s *.txtCMD Copy
Search every sub-folder for .txt files
> dir /o-dCMD Copy
Newest first
PS> Get-ChildItem -ForcePowerShell Copy
List everything including hidden items (alias: ls, gci)
PS> Get-ChildItem -Recurse -Filter *.logPowerShell Copy
Find all .log files below here
# pwd / Get-LocationShow the current folder
Syntax cd | Get-Location
> cdCMD Copy
In CMD, typing cd alone prints the current folder
PS> Get-LocationPowerShell Copy
Print the current folder (alias: pwd)
# mkdir / New-ItemCreate a folder
Syntax mkdir name
> mkdir ReportsCMD Copy
Create a folder
> mkdir Reports\2026\OctoberCMD Copy
CMD creates the whole chain automatically
PS> New-Item -ItemType Directory -Path ReportsPowerShell Copy
Create a folder in PowerShell
# rmdir / Remove-ItemDelete a folder
Syntax rmdir [/s] [/q] name
> rmdir EmptyFolderCMD Copy
Remove an empty folder
> rmdir /s /q OldBuildCMD Copy
Remove a folder and everything in it without asking
PS> Remove-Item -Recurse -Force OldBuildPowerShell Copy
The PowerShell way
Careful Deleted files do not go to the Recycle Bin when you use these commands. Check the path carefully.
# copy / xcopy / robocopyCopy files
Syntax copy source destination
> copy report.docx D:\Backup\CMD Copy
Copy a file
> xcopy Photos D:\Backup\Photos /E /ICMD Copy
Copy a folder with sub-folders
> robocopy C:\Data D:\Backup /MIRCMD Copy
Make D:\Backup an exact mirror of C:\Data (deletes extra files!)
> robocopy C:\Data D:\Backup /E /R:2 /W:5CMD Copy
Copy everything, retry twice, wait five seconds
PS> Copy-Item -Recurse C:\Data D:\BackupPowerShell Copy
PowerShell copy
Tip robocopy is the best choice for big copies: it resumes and can retry on errors.
# move / renMove or rename
Syntax move source destination | ren old new
> move report.docx D:\Archive\CMD Copy
Move a file
> ren notes.txt notes-old.txtCMD Copy
Rename a file
PS> Move-Item old.txt D:\Archive\PowerShell Copy
PowerShell move
PS> Rename-Item old.txt new.txtPowerShell Copy
PowerShell rename
# del / eraseDelete files
Syntax del [options] file
> del temp.txtCMD Copy
Delete a file
> del /q *.tmpCMD Copy
Delete without asking
> del /f /q readonly.txtCMD Copy
Force-delete a read-only file
PS> Remove-Item *.tmpPowerShell Copy
PowerShell delete
# type / Get-ContentShow a file
Syntax type file
> type notes.txtCMD Copy
Print the file
> more notes.txtCMD Copy
Print one page at a time (Space for next page)
PS> Get-Content app.log -Tail 50PowerShell Copy
Last 50 lines
PS> Get-Content app.log -WaitPowerShell Copy
Keep watching new lines (Ctrl+C to stop)
# mklinkCreate a link
Syntax mklink [/D] link target
# treeShow folders as a tree
Syntax tree [path] [/F]
> tree /FCMD Copy
Show folders and files
# attribFile attributes
Syntax attrib [+r|-r|+h|-h] file
> attrib +h secret.txtCMD Copy
Hide a file
> attrib -r file.txtCMD Copy
Remove the read-only flag
# notepad / codeOpen an editor
Syntax notepad file