Aqui está um script Powershell que renomeia automaticamente todos os arquivos em uma determinada pasta, desde que o script esteja aberto e em execução
### SET FOLDER TO WATCH + SUBFOLDERS YES/NO
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "C:\Users\nixda\Desktop\test"
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true
### SET ACTION AFTER A FILE IS CREATED
$action = {
$item = Get-Item -path $Event.SourceEventArgs.FullPath
if (-not $item.PSIsContainer) {
$date = Get-Date $item.CreationTime -format yy-MM-dd
$folder = $item.DirectoryName -replace '\', '-' -replace ':'
$newName = "$($date)_$($folder)_$($item.Name)"
### IF PATH ALREADY EXISTS, INCREMENT NUMBER UNTIL WE HAVE A FREE NAME
$fullPath = "$($item.Directory)/$newName"
while (Test-Path -Path $fullPath){
$i++
$newName = "$($date)_$($folder)_$($item.BaseName) ($i).$($item.Extension)"
$fullPath = "$($item.Directory)/$newName"
}
Rename-Item $item -newName $newName
}
}
### SET WHICH FILE EVENTS SHOULD BE WATCHED
Register-ObjectEvent $watcher "Created" -Action $action
while ($true) {sleep 5}