0
votes

How can I batch append a directory of files using the window cmd so that they change from.

"file1" "file2" "file3"

to

"001 file1" "002 file2" "003 file3"

1

1 Answers

0
votes

If you're willing to PowerShell instead of batch, you could do this as a one-off:

gci |% { ren $_ (('{0:d3} ' -f $i++) + $_.Name) }

Which is more fully written as:

$counter = 0
Get-ChildItem | ForEach-Object { 
    $prefix = '{0:d3}' -f $counter++
    Rename-Item -Path $_.FullName -NewName "$prefix $($_.Name)"
}