bash script to renumber screenshots

Shuffleblast

Diabloii.Net Member
As you all know, d2 screenshots automatically get a number starting at 001. Now if you're like me and like to keep them in a separate folder, there comes a time when you need to move the newly made screenshots. Since they also start at 001, a naming conflict ensues and if you're lazy like me, you might have to rename 100 files for the upcoming RFL.

Tedious!

Here's a bash script to rename those new screenshots. For those wondering what this is, it's a .sh file that you run in a linux terminal or a program like cygwin on windows. To be safe when renaming, you should:
- make a new folder
- copy the .sh script into that folder
- copy the screenshots you want to rename into that folder (so you still have a backup)
- run the .sh from that folder

#!/bin/bash
FILES=$(ls *.jpg)
read -p "Start new names with number: " NUMBER
for FILE in $FILES; do
printf "Renaming $FILE to Screenshot%03d.jpg\n" "$NUMBER"
mv $FILE `printf %s%03d%s Screenshot $NUMBER .jpg`
((NUMBER++))
done
 

Attachments

Last edited:

Shuffleblast

Diabloii.Net Member
Made a small edit to get the NUMBER through user input instead of having it hardcoded (read -p "Start new names with number: " NUMBER).
 

T72on1

Diabloii.Net Member
Hmm, some useful info in here.

I keep my pics in seperate folders as well, but don't just keep the number that is given by the game. Instead they are named after the character / event they are about, then the number of the last picture +1, then what the pic is about. For example Neverland_72_Zod 4 .

I'll have to see if I can easily do this with one of the programs listed here.
 

ioupainmax

Diabloii.Net Member
You can with Bulk Rename Utility.

You can use regular expressions, you can use prefixes and suffixes, you can autonumber, you can add padding etc.
 

sir_cyclops

Diabloii.Net Member
All of these feel like workarounds. It wouldn’t be too bad to write a script that would run constantly (or be a scheduled task) to just cp (copy) or mv (move) all the screenshots into another folder and number then according to highest number one already in there. Maybe I'll write this soon enough. Python (python compiled into an exe) might be best for multiple OS. Thoughts?
 
Last edited:

T72on1

Diabloii.Net Member
All of these feel like workarounds. It wouldn’t be too bad to write a script that would run constantly (or be a scheduled task) to just cp (copy) or mv (move) all the screenshots into another folder and number then according to highest number one already in there. Maybe I'll write this soon enough. Python (python compiled into an exe) might be best for multiple OS. Thoughts?
How would the game know which folder the screen has to go into?
 

sir_cyclops

Diabloii.Net Member
How would the game know which folder the screen has to go into?
Your use case is a little different, but you could actually do what you want with an autohotkey script. Just have prtscn followed by a 1 go to "rune folder" or prtscrn followed by a 2 get saved to "blizz sorc" folder or whatever.
 

Shuffleblast

Diabloii.Net Member
All of these feel like workarounds. It wouldn’t be too bad to write a script that would run constantly (or be a scheduled task) to just cp (copy) or mv (move) all the screenshots into another folder and number then according to highest number one already in there. Maybe I'll write this soon enough. Python (python compiled into an exe) might be best for multiple OS. Thoughts?
No idea honestly. :)

I just did it this way because after every year or two when I go to sort the screenshots, I delete some of the less spectacular ones and then I can just run the script and it'll renumber them accordingly. Having a proper program like some folks here also works, but I just don't need it.
 

Ghonn

Diabloii.Net Member
I'm nearing 999 screenshots quite soon. Already running over 900. Somehow I remember reading that taking too many screenshots might crash the game, and I'd _hate_ that happening when a DF or Griffon's finally shows up and I'm taking a drop pic of it. Not sure about crashing, but I don't want to rename or move the screenshots unless it really is necessary.

Naming scheme hints that 999 is the maximum amount. Is it? What happens after? Maybe I'll try by myself when I get home
 
Top