1. remove some text on file name of all files: e.g. “TVBOXNOW ”
1 |
ls | Rename-Item -NewName { $_.name -replace "TVBOXNOW ", "" } |
2. move up one level of files in each directory, e.g. c:\folder1\folder2\file3 to c:\folder1\file3
1 2 3 4 5 6 |
$files = Get-ChildItem -Recurse "c:\folder1" | where {$_.PSIScontainer -eq $false} foreach ($file in $files) { $destinationFolder = Split-Path -Parent $file.Directory.FullName move-item $file.FullName $destinationFolder } |
3. Remove files by extension for all subdirectories: e.g. .url / .nfo
1 |
Get-ChildItem -File -Include *.url,*.nfo -Recurse | foreach ($_) {Remove-Item $_.FullName} |
4. see unique file extension in all subdirectories
1 |
Get-Childitem -File -Recurse | Select-Object Extension -Unique |
5. file name format: xxxx.2013.zzzz, …