archive separate files with winrar

May 22, 2009 at 01:44:29
Specs: Windows XP, 3.4
hi i need a batch code (.bat ) for archive my files with winrar
in my current folder there is a folder called "company"
there is a program that copy some different files every few days or week to company folder
names of files that are being copied=
daily updat.exe
weekly source.exe
other files= (*.exe *.dll *sys * dat)
what i need =
1- i want to compress every file in a separate .rar archive
2- program should search for (daily updat.exe , weekly source.exe patch.exe )if find them compress them one by one
3- sometimes there is just one or 2 of them so if it did'nt find 1 file it should search for other ones
4- program should not add folder to archived rar file just add each file without adding "container" folder to archive or any folder
5-if program find other (.exe .dll .sys .dat ) files it should add them all to one rar archive (all together) and name it other files.rar

i found this code but it work correct if all files exist or it wont work ok

cd company\
set path=C:\program files\winrar\;%path%
winrar a -ibck daily updat.exe

See More: archive separate files with winrar

Report •

May 22, 2009 at 02:58:51
cd company
path C:\Program Files\WinRAR;%path%
for %%f in ("daily updat.exe" "weekly source.exe" patch.exe) do (
   if exist %%f rar a -m5 %%~nf %%f
rar a -m5 -x"daily updat.exe" -x"weekly source.exe" -xpatch.exe "other files" *.exe *.dll *.sys *.dat

Report •

May 22, 2009 at 14:19:29
thank you very very much dear klint
i was stuck in this problem for a week
you saved me
its working very nice
thanks again
god bless you

Report •

May 22, 2009 at 21:00:28
ok here's my last question=

in path
path C:\Program Files\WinRAR;%path%

what if in another pc winrar was installed on another drive or location?
i know that i can change path manualy but because i want to turn these batch code into exe is there any other way for future?
for example=
user make a txt file in drive C:
and name it path winrar.txt and type winrar exact path
is it possible for this batch code to search for winrar and if it was path C:\Program Files\WinRAR;%path%
ok everything is correct and can continue but if it was not search for C:\path winrar.txt to find the winrar address?
and then go to next line in batch codes and continue the rest?
if its possible put the codes for batch code and example .txt file
thank you very very much

Report •

Related Solutions

May 23, 2009 at 05:18:31
assuming winrar is installed

C:\>ftype winrar
winrar="C:\Program Files\WinRAR\WinRAR.exe" "%1"

Report •

May 23, 2009 at 05:27:47
sorry dear reno can you tell me what above command does?
i put it in a batch file but it made a file named=ftype
what is it?

Report •

May 23, 2009 at 09:12:53
@echo off & setlocal

for /f "tokens=*" %%a in ('ftype winrar') do set %%a
set winrar=%winrar:" "="&REM.%
set winrar

%winrar% a test.rar *.txt

sample bat script using ftype, that load the command line for winrar.

Report •

May 23, 2009 at 12:33:15
thanks dear reno
your cods working woderfull even faster than before !!
i tried it in 2 windows drive C and D
thanks again

Report •

Ask Question