Computing.Net > Forums > Programming > archive separate files with winrar

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

archive separate files with winrar

Reply to Message Icon

Name: niki chan
Date: May 22, 2009 at 01:44:29 Pacific
OS: Windows XP
CPU/Ram: 3.4
Subcategory: Batch
Comment:

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.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



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: May 22, 2009 at 02:58:51 Pacific
Reply:

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


0

Response Number 2
Name: niki chan
Date: May 22, 2009 at 14:19:29 Pacific
Reply:

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


0

Response Number 3
Name: niki chan
Date: May 22, 2009 at 21:00:28 Pacific
Reply:

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


0

Response Number 4
Name: reno
Date: May 23, 2009 at 05:18:31 Pacific
Reply:

assuming winrar is installed

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


0

Response Number 5
Name: niki chan
Date: May 23, 2009 at 05:27:47 Pacific
Reply:

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?


0

Related Posts

See More



Response Number 6
Name: reno
Date: May 23, 2009 at 09:12:53 Pacific
Reply:

@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.


0

Response Number 7
Name: niki chan
Date: May 23, 2009 at 12:33:15 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

script for retriving a pa... Extract file created date...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: archive separate files with winrar

editing text file with batch file www.computing.net/answers/programming/editing-text-file-with-batch-file/15231.html

Ghost *.Bat File With Auto Naming? www.computing.net/answers/programming/ghost-bat-file-with-auto-naming/12740.html

Create file with mac address www.computing.net/answers/programming/create-file-with-mac-address/9789.html