How to rename, sort and organise files, based on filename using PowerShell.
The following PowerShell script takes a list of files in a given folder, creates a new folder based on the given filename, and moves the given file, into that fold.foreach($file in (Get-ChildItem 'x:\vol\movies\renew' | Where {(-not $_.PSIsContainer) -and (-not $_.PSIsContainer)})) {New-Item -Path (Split-Path $file.fullname) -Name (Split-Path $file.fullname -Leaf).ToString().Replace(".avi","") -ItemType Directory Move-Item -Path $file.fullname -Destination "$(Split-Path $file.fullname)\$((Split-Path $file.fullname -Leaf).ToString().Replace('.avi',''))"}
No comments:
Post a Comment