Tuesday, 21 March 2017



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

Fixing Java KVM client error with 'Connection Failed'

Java 8u171 disables the use of the 3DES_EDE_CBC cipher. Solution is to reconfigure Java by editing and removing 3DES_EDE_CBC from the follow...