| task |
Windows PowerShell |
Bash |
| list all files in current directory |
get-childitem |
ls -lh -1 |
| list files in directory, name only |
ls -name |
ls -1 |
| list files in directory, filter by file type |
get-childitem -filter "*.pdf" |
find . -name "*.pdf" |
| list files in directory, filter by file type AND only print file names |
get-childitem -name -filter "*.pdf" |
|
| list files in directory, filter by multiple file types |
get-childitem -file | where-object { $_.Extension -in ".pdf", ".mp3" } |
|
| list files in directory, filter by the beginning of a file name |
get-childitem -filter "*2024*" |
|
| list files in directory, filter by the beginning of a file name AND file type |
get-childitem -filter "2024_*.pdf" |
|
| list files in directory, sort by largest to smallest |
get-childitem -file | sort-object -property length -descending |
ls -laS -lh |
| list files in directory, show 10 largest files |
get-childitem -file | sort-object -property length -descending | select-object -first 10 |
ls -laS -lh | head -n 10 |
| list files in directory, filter by files larger than x-size |
get-childitem -file | where-object { $_.Length -gt 100mb} |
find . -type f -size +100M |
| list files in directory, filter by files within a size range |
get-childitem -file | where-object { $_.Length -gt 10mb -and $_.Length -lt 100mb } |
|
| list files in directory, show in alphabetical order |
get-childitem | sort-object -property name |
ls |
| list files in directory, show only file names in alphabetical order |
|
ls |
| list files in directory, sort by last edited (newest-to-oldest) |
get-childitem -file | sort-object -property lastwritetime -descending |
ls -t |
| list files in directory, sort by 10 most recently edited |
get-childitem -file | sort-object -property lastwritetime -descending | select-object -first 10 |
ls -t -1 | head -10 |
| list files in directory, sort by 10 least recently edited |
get-childitem -file | sort-object -property lastwritetime -ascending | select-object -first 10 |
ls -lh -ltr -1 | head -10 |
| list files in directory in table view |
get-childitem | format-table -autosize name, length, lastwritetime |
|
| list files in directory, show count of each file type |
get-childitem -recurse -file | group-object extension | sort-object count -descending |
|
| list files in directory, export to txt file |
ls -name >> inventory.txt |
ls > inventory.txt |
| list files in directory, export file paths to txt |
|
|
| list all hidden files in directory |
|
ls -a -1 |
| locate a specific file |
|
find ~/Documents -name "1994report.jpg" |
| locate a file based on file type |
get-childitem -recurse -filter "*.wav" |
|
| task |
Windows PowerShell |
Bash |
| create a file |
|
touch test.txt\
Spaces not allowed. Use underscore or no spaces |
| rename a file |
rename-item "2014-agenda.doc" -newname "2015-agenda.doc" |
mv 2014-agenda.doc 2015-agenda.doc |
| rename multiple files |
|
|
| convert file type (image files) |
|
|
| convert file type (audiovisual files) |
|
ffmpeg -i interview.mp3 interview.wav |
| check image file metadata |
|
exiftool eventphotos.jpg |
| remove all image file metadata |
|
exiftool -all= eventphotos.jpg |
| replace spaces with underscores in all file names in a directory |
|
rename 's/ /_/g' *
To install "rename," run: sudo apt install rename |
| remove spaces in all file names in a directory |
|
rename 's/ //g' * |
Blue text indicates a placeholder example and should be replaced with your specific information.