problem intro:
Dead Island game crashes once save file exceeds certain file size. Files are archives, but with .sav extension rather than .zip.
I want to make a script that will loop through *.sav files, copy them to another location with same file name, but as *.zip, then extract them, check extracted file size, and alert me if file size exceeds the limit.
So far, I got this:
@ECHO OFF
setlocal enableextensions enabledelayedexpansion
FOR %%i IN ("D:\Games\Dead Island\out\save\"*.sav) DO (
set str=
set str=!str!%%i
set str=!str:.sav=.zip!
echo !str!
copy %%i !str!
)
PAUSE
for some reason bat files have problems assigning values to variables within FOR loops, so I found a solution to use delayedexpansion.
but currently my biggest problem is that it just wont copy save_1.sav to another location with name save_1.zip!
once I get past this, I will dive into 7zip unpacking and file size verification (along with all other stuff needed), but this is just frustrating 🙂
maybe I should just do this in python…
If you want to change the file extension of something, you can use
%%~n<variable>to get the stem, like so (taken from one of my batch files):This might be useful:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true
In your case, I guess you could just do something like:
(Just tested this at the command line — where you use % instead of %% if you want to try it — and it works.)