Skip to content

Instantly share code, notes, and snippets.

@Sarverott
Last active April 10, 2023 17:38
Show Gist options
  • Save Sarverott/9ece5f2ef2d9b2ee154fdd5aeb8351b9 to your computer and use it in GitHub Desktop.
Save Sarverott/9ece5f2ef2d9b2ee154fdd5aeb8351b9 to your computer and use it in GitHub Desktop.
simple script to rename long-named images from camera or download directory [[[ **WARNING:** errors or infinite loop possibility ]]]
rem Sett Sarverott @ 2017
rem image-renamer.bat [from-directory-path] [to-directory-path] [extension-without-dot]
rem ###
rem example of use: START /w /b .\image-renamer.bat E:\path\from\camera-files-with-long-names E:\path\to\camera-files-with-long-names jpg
dir /b "%1" >".\_picture-list.txt"
set picturecounter=1
pause
:g
copy ".\_picture-list.txt" ".\_picture-list.temporary.txt"
set /p currentnameimg= <".\_picture-list.temporary.txt"
ren "%1\%currentnameimg%" "%2\%picturecounter%.%3"
set /a picturecounter = %picturecounter%+1
type ".\_picture-list.temporary.txt" | find /v "%currentnameimg%" >".\_picture-dir-list.tmp.txt"
del ".\_picture-list.temporary.txt"
goto g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment