Quick bat file help

Don
Joined
21 Oct 2002
Posts
46,828
Location
Parts Unknown
say a bat file is creating file.txt

i want to put something in, so if file.txt exists, when it comes to save, it creates filea.txt

if file a exists, then create fileb.txt

-ie, instead of overwriting or appending the current files, just adding a new letter to the end of it

this won't happen more than 10 times a day, so i won't run out of the alphabet..


can anyone help :)


i know it's something like..

file%%i.txt if %%i exists %%i = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,w,y,z)



just not sure how to write it
 
Kronologic

i've got the file doing this..

@echo off
title close my documents..
color c7
echo Close all My Documents..
@echo off
pause
color 17

::date code

FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :s_fixdate %%G %%H %%I %%J)
goto :s_print_the_date

:s_fixdate
if "%1:~0,1%" GTR "9" shift
FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (
set %%G=%1&set %%H=%2&set %%I=%3)
goto :eof

:s_print_the_date

ENDLOCAL&SET mm=%mm%&SET dd=%dd%&SET yy=%yy%
::date code

title 7zip backup..
echo

7za.exe a -mx=9 E:\Bleddyn\backups\%dd%-%mm%-%yy%.7z "%userprofile%\My Documents\" -x!"My Documents\tempSimsRpt\" -x!"My Documents\My SIMS Documents\"
@echo off
color a0

title all done
echo all done
@echo off
pause

which names the backups.. 28-01-2008.7z , i'm hoping to add the letters so i can run this more than once a day without having to manually edit the filename..

whitecrook, that looks like what i need, but i'm a bit of a bat file noobie.. i'd like to keep it all in one file if poss, thanks for the info :)
 
i ended up just chucking this in, i'm not good enough at bat files to get my head around what you wrote :/ tried using it with my file, but couldn't get it working

so this is what i'm using now, looks crap & wastes space in the file, but it's working perfectly

set v=a
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%a.7z set v=b
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%b.7z set v=c
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%c.7z set v=d
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%d.7z set v=e
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%e.7z set v=f
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%f.7z set v=g
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%g.7z set v=h
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%h.7z set v=i
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%i.7z set v=j
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%j.7z set v=k
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%k.7z set v=l
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%l.7z set v=m
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%m.7z set v=n
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%n.7z set v=o
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%o.7z set v=p
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%p.7z set v=q
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%q.7z set v=r
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%r.7z set v=s
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%s.7z set v=t
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%t.7z set v=u
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%u.7z set v=v
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%v.7z set v=w
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%w.7z set v=x
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%x.7z set v=y
if exist E:\Bleddyn\backups\%dd%-%mm%-%yy%y.7z set v=z


::v being the letter for the filename, so i make the file... E:\Bleddyn\backups\%dd%-%mm%-%yy%%v%.7z
 
bluestreak

a good way of refreshening the map is to unmap, then remap it..

@Echo off
net use h: /d
net use h: \\pcname\sharename
if not exist h:\ goto error
set CURRDATE=%DATE:/=-%
mkdir "H:\Pictures %currdate%"
xcopy "I:\DCIM\*.jpg" "H:\Pictures %currdate%\"
del I:\DCIM\*.jpg /Q
echo All done, no problems
goto end

:error
echo h: not found

:end
pause




should work

thanks for the date tip rpstewart, the one i was using works internationally i think, but i only need a uk one :)
 
Last edited:
Back
Top Bottom