Bulk renaming of files in PowerShell with sequential numeric suffixes

后端 未结 3 1285
刺人心
刺人心 2020-12-02 17:52

I have 14,000 pictures sorted into files by year and month but taken with multiple cameras and I want the file name to reflect the date taken. For example October 16, 1998 p

3条回答
  •  一个人的身影
    2020-12-02 18:17

    $path="C:\..."
    $files=Get-ChildItem $path -Filter *.gif  
    Foreach($obj in $files){
       $pathWithFilename=$path + $obj.Name;
       $newFilename= "file_"+$obj.Name; 
    
       Rename-Item -Path $pathWithFilename -NewName $name
    }
    

    You can use this code blocks in powershell ISE. Example output like this :

    Old files :

    1232.gif asd.gif

    After run code :

    file_1232.gif file_asd.gif

提交回复
热议问题