Code: Select all
Echo off
set YEAR=%DATE:~6,4%
set "last=0"
set "filename=C:\Users\PP_lemev\Desktop\Newfolder\01_%YEAR%.7z"
cd C:\Users\PP_lemev\Desktop\Newfolder
if not exist "C:\Users\PP_lemev\Desktop\Newfolder\01_%YEAR%" mkdir "C:\Users\PP_lemev\Desktop\Newfolder\01_%YEAR%"
for /d %%X in (01_%YEAR%) do "C:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\"
if exist "C:\Users\PP_lemev\Desktop\Newfolder\Newfolder\01_%YEAR%.7z" (
for /R %%i in ("C:\Users\PP_lemev\Desktop\Newfolder\01_%YEAR%(*).7z") do (
for /F "tokens=2 delims=(^)" %%a in ("%%i") do set "last=%%a"
)
set/a last+=1
set "filename=C:\User\PP_lemev\Desktop\Newfolder\01_%YEAR%(%last%).7z"
)
mkdir "C:
pause
MOVE "%filename%" "C:\Users\PP_lemev\Desktop\Newfolder\Newfolder"
So, basicly my problem is, When I am done making archive and send it to another folder, everything works fine. But If run my script again, It will replace first archive, and "important" data will be lost. So, this script checks if Archive exists, and if it does, it renames new archive and only then moves it to new folder. New archive should look like this in the end 01_2016(1).7z.
Error output:
The system cannot find the path specified.
Any Ideas how to fix this?
Thank you for any help!