Use this when working with Windows paths, file operations, long paths or UNC paths.
Files & Directories
Files and directories in Windows are organized in a tree on each volume, addressed by drive-letter paths or UNC paths, and managed with File Explorer, cmd, PowerShell and robocopy.
1. Test-Path <path> — exists?
2. Get-Acl <path> — access?
3. Hidden/system? Get-ChildItem -Force.
4. Long or special path?
5. Copy with robocopy for large or metadata-preserving copies.
path → volume → directory → file → ACL check
Context & applicabilityCommon mistakes · platform/version boundaries
- Using
xcopyinstead ofrobocopyfor large copies (no retry, no ACLs by default). robocopy /MIRagainst the wrong target, deleting files.- Forgetting
-LiteralPathin PowerShell for names with[or].
Operational reference
Fast context before you go deeper.
robocopyPrimary Commands
Configuration and operational commands for this Topic.
robocopyReferenceCopy files robustly with retries and mirroring.
Windows / Windows Server / PowerShell · mixedxcopyReferenceCopy files and directory trees (legacy; prefer robocopy).
Windows / Windows Server / PowerShell · mixedcopyReferenceCopy files in Command Prompt.
Windows / Windows Server / PowerShell · mixedmoveReferenceMove files in Command Prompt.
Windows / Windows Server / PowerShell · mixeddelReferenceDelete files in Command Prompt.
Windows / Windows Server / PowerShell · mixedmkdirReferenceCreate a directory.
Windows / Windows Server / PowerShell · mixedrmdirReferenceRemove a directory.
Windows / Windows Server / PowerShell · mixedSubtopics
Go one level deeper into this subject.
File Explorer is the Windows graphical file manager for browsing, copying, searching and sharing files, showing file extensions, hidden files, previous versions and properties such as security permissions.
Subtopic PathsWindows paths can be absolute (C:\Users\pat\file.txt), relative (.\data), UNC (\\server\share\file) or device paths (\\?\C:\).
Subtopic UNC PathsA UNC path names a network resource as \\server\share\folder\file, without a drive letter.
Subtopic Long PathsLong paths over 260 characters (MAX_PATH) fail in many Windows apps.
Subtopic File Operations TroubleshootingTroubleshoot file operations by checking permissions and ownership, files locked by another process (Resource Monitor, handle.exe), path length, read-only or system attributes, free space and antivirus blocking.
- MAX_PATH 260 still breaks many apps.
- UNC uses Kerberos by name, NTLM by IP.
- Locked files block moves and deletes.
Get-ChildItem <path> -Force— contents including hiddenTest-Path <path>— exists?Resolve-Path <path>— full pathGet-Item <path> | fl *— attributes and timestamps
ReferenceHow it works1 section · depth on demand
In depth
Everyday file operations from the command line:
| Task | PowerShell | cmd |
|---|---|---|
| List | Get-ChildItem -Force | dir /a |
| Copy tree with ACLs | robocopy src dst /E /COPYALL /R:1 /W:1 | same |
| Mirror | robocopy src dst /MIR (deletes extras) | same |
| Find big files | Get-ChildItem -Recurse -File \| Sort Length -Desc \| Select -First 20 | — |
| Delete tree | Remove-Item -Recurse -Force | rd /s /q |
| Hash | Get-FileHash -Algorithm SHA256 | certutil -hashfile f SHA256 |
robocopy exit codes 0–7 mean success (8+ are failures) — scripts must not treat 1 as an error.
ReferenceImportant terms & boundaries1 section · depth on demand
PowerShell equivalents
| cmd | PowerShell |
|---|---|
dir /s | Get-ChildItem -Recurse |
copy / xcopy | Copy-Item (or robocopy) |
move | Move-Item |
del | Remove-Item |
mkdir | New-Item -ItemType Directory |
type | Get-Content |
icacls | Get-Acl / Set-Acl |
ReferenceConfiguration & state1 section · depth on demand
Useful commands
| Task | cmd | PowerShell |
|---|---|---|
| List | dir /a | Get-ChildItem -Force |
| Copy | copy, robocopy | Copy-Item |
| Move/rename | move, ren | Move-Item, Rename-Item |
| Delete | del, rd /s | Remove-Item -Recurse |
| Find | where /r C:\ file.txt | Get-ChildItem -Recurse -Filter |
| Size | dir /s | (Get-ChildItem -Recurse | Measure Length -Sum).Sum |
Use robocopy for large or resumable copies with permissions (/MIR /COPYALL /R:1 /W:1).
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Files & Directories. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/windows-server/storage/file-server/ntfs-overview · confidence 94%