XP Batch scripting - zipping with rinrar scrolling through * .csv directory
I have read numerous articles now and it is not clear and there are many versions and it is both, and I have been piecing things together and so far, my problem is the "rar" command doesn't seem to accept my substitution variable and instead then read it as a string.
But this is what I have
@echo off
SETLOCAL
set path =% path%; "C: \ TEMP \ Output"
set _sourcedir = C: \ TEMP \ Output
set _logfile = c: \ temp \ Output \ zip_log.txt
set _rarpath = C: \ Program Files (x86) \ WinRAR
echo Run rar batch>% _logfile%
:: Set default directory
pushd% _sourcedir%
echo Scan Directory% _sourcedir%
FOR %% f IN (* .txt) DO (
echo %% f
% _ rarpath \ rar.exe test
)
POPD
ENDLOCAL
@echo on
I cut and cut it a bit so you just get the point, but I didn't miss any commands.
I am trying to loop through a directory and find all the .txt files and zip em. (rar em)
Echo writes the correct filenames.
Any ideas?
I think this is your problem:
set _rarpath=C:\Program Files (x86)\WinRAR
In batch files, the environment variable separator is a space, so it thinks that _rarpath
-C:\Program
Close the path in double quotes and see if that helps:
set _rarpath="C:\Program Files (x86)\WinRAR"
Also, in your change of the FOR loop
%_rarpath\rar.exe a test
to
%_rarpath%\rar.exe a test
(or perhaps it was a typo?)
I can't see where you are asking winrar to do anything with your files? %% f should be somewhere on the winrar command line.
Also, you don't need a loop for this: rar.exe test.rar% yourpath% *. csv or similar.