Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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
patch.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.rari 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

Untested:
setlocal 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

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

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

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?

@echo off & setlocal
for /f "tokens=*" %%a in ('ftype winrar') do set %%a
set winrar=%winrar:" "="&REM.%
set winrar:testing
%winrar% a test.rar *.txt
sample bat script using ftype, that load the command line for winrar.

thanks dear reno
your cods working woderfull even faster than before !!
i tried it in 2 windows drive C and D
perfect
thanks again

![]() |
script for retriving a pa...
|
Extract file created date...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |