# encoding: ascii
# api: powershell
# title: Renaming folder names
# description: I just want to rename the folder names in particular path where folder name starts with keep all characters by dropping if “12_” before the file name. I am able to rename it but not able to get log file for the following script.
# version: 0.1
# type: script
# author: Srinu
# license: CC0
# x-poshcode-id: 6088
# x-archived: 2015-11-13T23:43:39
# x-published: 2015-11-12T17:06:00
#
#
$Folders = Get-ChildItem 'E:\Root Folder\12_*'

$collection = $()
Foreach ($Folder in $Folders)

{

$status = @{ "OldFolderName" = $Folder.Name; "NewFolderName" = $Folder.Name.Substring(3); "TimeStamp" = (Get-Date -f yyyy:MM:dd-hh:mm:ss) }

$NewFolderName = $Folder.Name.Substring(3); 
Rename-Item -Path $Folder -NewName $NewFolderName

New-Object -TypeName PSObject -Property $Status 
  
}

$collection | Out-File D:\$((Get-Date).ToString('yyyyMMdd'))_Renaming_Folder_Names_script_Log.txt -Append
