简体   繁体   中英

Using Powershell rename files with serial number based on order of Last modified

I now have 2600 images in a folder I want to rename with a serial number starter from 1.jpg, 2.jpg, 3.jpg and so on. I want to start with the oldest files first and rename them as mentioned.

One file can be qwe01.jpg Last modified 01.05.2012 next file can be ewe202.jpg Last modified 05.05.2012 and so on...

I want these to be renamed in the correct order based on the date modified.

这没有经过完全测试,但是应该可以工作:

$count = 1; Get-ChildItem -file | Sort-Object LastWriteTime | %{$newName = '{0}{1:00}.{2}' -f $_.basename, $count, $_.extension; Rename-Item $_ -NewName $newName; $count++}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM