So I have a very simple script set up on the task scheduler to move screenshots once a day from one folder to another. Thats working fine, but when the screenshots are taken, they are automatically give a name by Steam, e.g. "Screenshot.png", "Screenshot 1.png", "Screenshot 2.png" etc depending on how many are in the folder. So when the files are emptied in to the other folder each day, every set of screenshots taken on that day start again at "Screenshot.png" and go up from there. The result is that when they are moved, they are going to be either overwriting or appending (1) or something (not sure which as haven't had this running yet!)
So I want to change the following batch file to find the highest number in "Screenshot xxx.png" in the destination folder, add one, rename the file in the source folder to this number and then do the move. This will have to fit in a loop so it can go through all files in the source folder.
@echo off
set X=1
set "source=C:\Users\Leigh\AppData\Local\Colossal Order\Cities_Skylines\Screenshots"
set "destination=D:\Leigh\Pictures\SkyLinesScreenshots"
robocopy "%source%" "%destination%" /mov
exit /b
I had a play and found a script to determine which the next number should be, but couldnt get the regex right:
@echo off
setlocal enableextensions disabledelayedexpansion
setlocal enabledelayedexpansion
set "nextFile=0" & for /f "delims=" %%a in ('
findstr /b /r /x
/c:"\bScreenshot\b\s[0-9]+\.png"
') do if %%~na geq !nextFile! set /a "nextFile=%%~na+1"
endlocal & set "nextFile=%nextFile%"
echo Next file will be: %nextFile%
If I get that right I will integrate them together and work out the problem. This is pretty clear what needs doing, so could anyone either give me the correct regex, or even more if they so wish.
Thanks in Advance!