Zenfolio | Sublime Light Landscape Photography | How to Batch Rename Large Numbers of Files Using Powershell

How to Batch Rename Large Numbers of Files Using Powershell

January 20, 2018  •  Leave a Comment

 

Zenfolio, my website hosting company, does not have the capability to randomly sort images within a gallery.  I felt that randomly sorting images would create a much better presentation.  I did not want to install new software on my workstation, so I searched the web for native functionality within Microsoft Windows 10 to batch-rename files, specifically, to prepend random numbers to the existing file names.  I did not find the exact method I wanted, but I was able to infer a method.


It's pretty simple. 

 

1. On your desktop (or other location of your choosing), create a folder to house the photo files that will be renamed.  Example: C:\Users\Jeff\Desktop\Test

2. Copy your photo files to the "Test" folder.  I suggest using copies of the images rather than moving the files, so that you can create a different random order in the future

3. Open Powershell

4. Change the Powershell directory to the "Test" folder.  This is VERY important.  Otherwise you will likely rename every file that resides under your user name.  Example: Type "cd c:\Users\Jeff\Desktop\Test", then press Enter

5. Type "Get-ChildItem | rename-item -NewName { ((get-random  -minimum 1000 –maximum 9997 ).tostring()) + ”__” + $_.Name }", then press Enter.  This will rename every file within the Test folder.  It prepends a random number between 1000 and 9997, followed by "__".  Example: 4562__Photo Name

6. After uploading the renamed photos to a Zenfolio gallery, sort by File Name

 

That's it.

 

Jeff

 


Comments

No comments posted.
Loading...