Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

WinRar Command line help

Posted on 2007-11-29
7
Medium Priority
?
17,978 Views
Last Modified: 2013-12-01
OK, I want to compress certain files for about 80 users and rather than writing individual batch files for each person I just went and hid the folders of non-important files.

Now the problem I'm having is that WinRAR command line only seems to exlude hidden FILES, not folders. Which isn't really working for me, and I'd prefer to not hide all of thefiles. Is there a way to exclude hidden folders instead of files?? I know winZIP does it but well.....WinRAR is so much better.

Heres what my current test batch file looks like(E-mail is a hidden folder I want included)

c:\"program files"\WinRaR\WinRAR a -u -r -Eh c:\"UserData"\"Plist.rar" c:\"UserData"\Plist\*.*
c:\"program files"\WinRaR\WinRAR a -u -r -Eh c:\"UserData"\"Plist.rar" c:\"UserData"\Plist\E-mail\*.*

Open in new window

0
Comment
Question by:PCL3385
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 19

Expert Comment

by:Barthax
ID: 20382407
The DOS "FOR /D" syntax will exclude the hidden directories for you - but that means WinRAR must be executed for each folder.  Below is a quick knocked-up batch file to perform the action.  It takes two parameters: the first is the rar file to which the files are to be archived to & the second is the user's directory.  At the moment, you will notice both of the FOR statements have an @echo to show what would commands would get run (better for testing).


SET DESTRAR=%1
SET USERDIR=%2
SET WINRAR="C:\Program Files\WinRAR\WinRAR.exe"
SET WINRARCMD=%WINRAR% a -u -r
 
REM Assumes the batch file is on the same drive as the folder
REM If not remove the REM from the next line & adjust the letter:
REM C:
CD %USERDIR%
 
REM Do all the files (only) in the root directory
FOR %%f in (*.*) DO @echo %WINRARCMD% %DESTRAR% %%f
 
REM Do all the directories which are visible
FOR /D %%f in (*) DO @echo %WINRARCMD% %DESTRAR% %%f\*.*

Open in new window

0
 

Author Comment

by:PCL3385
ID: 20383377
Ok first off Thanks A lot for the help.
Sadly though, I believe my DOS knowledge is a bit lacking since I don't really understand what all i need to replace with actually directories.

My batch files are not in the same directory as the folder, it's on the local computer. And the folders are on our main server.
So i suppose my new question is could I get an example with actual directories so i know what I have to replace. Thanks again
0
 
LVL 19

Accepted Solution

by:
Barthax earned 2000 total points
ID: 20383481
How are you executing (or proposing to execute) the batch file - as that is key to how this batch file could work (i.e., I can adjust it to accomodate)?

I've modified the batch by wayof example and I've assumed that the data you want to back up is as your example.  I've also added the bit I forgot: the hidden E-mail subfolder. :)

Note that my original is more versatile as it takes parameters.  If you're not comfortable with the command line, that's fine & I'll concentrate on a double-click style solution. :)
SET DESTRAR="C:\UserData\Plist.rar"
SET USERDIR="C:\UserData\Plist"
SET WINRAR="C:\Program Files\WinRAR\WinRAR.exe"
SET WINRARCMD=%WINRAR% a -u -r
 
REM Assumes the batch file is on the same drive as the folder
REM If not remove the REM from the next line & adjust the letter:
C:
CD %USERDIR%
 
REM Do all the files (only) in the root directory
FOR %%f in (*.*) DO @echo %WINRARCMD% %DESTRAR% %%f
 
REM Do all the directories which are visible
FOR /D %%f in (*) DO @echo %WINRARCMD% %DESTRAR% %%f\*.*
 
%WINRARCMD% %DESTRAR% %%f\E-mail\*.*

Open in new window

0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 19

Expert Comment

by:Barthax
ID: 20383486
Bah, the following line:

%WINRARCMD% %DESTRAR% %%f\E-mail\*.*

(last line) should read:

%WINRARCMD% %DESTRAR% %USERDIR%\E-mail\*.*
0
 

Author Comment

by:PCL3385
ID: 20383643
I'm running straight from the batch file(it doesn't seem to work at command line though I am probably doing something wrong)
But the final product I will be running from Auto Task Manager.

One thing I forgot though those are not the actual directories merely test directories.

Here is the actual batch I was using, and the thing is, is that every user is in the 1 batch file.
Is that going to cause problems with this method?
c:\"program files"\WinRaR\WinRAR a -u -r -esh e:\"data files"\"User Data"\"Plist.rar" \\mglsrv1\"UserData"\Plist\*.*
c:\"program files"\WinRaR\WinRAR a -u -r -esh e:\"data files"\"User Data"\"Plist.rar" \\mglsrv1\"UserData"\Plist\E-mail\*.* 
 
c:\"program files"\WinRaR\WinRAR a -u -r -esh e:\"data files"\"User Data"\"Plist2.rar" \\mglsrv1\"UserData"\Plist2\*.*
c:\"program files"\WinRaR\WinRAR a -u -r -esh e:\"data files"\"User Data"\"Plist2.rar" \\mglsrv1\"UserData"\Plist2\E-mail\*.* 

Open in new window

0
 

Author Closing Comment

by:PCL3385
ID: 31411709
Very Good answer was just hard to understand because of my lack of DOS knowledge
0
 
LVL 19

Expert Comment

by:Barthax
ID: 20387657
Let's see if we can't get this working then. :)  If you have more then just the two directories, the add them onto the end of the SET USERS= line (with spaces between).

@ECHO OFF
SET USERS=Plist Plist2
SET DESTRAR=E:\data files\UserData\%1.rar
SET USERDIR=\\mglsrv1\UserData\%1
SET WINRAR="C:\Program Files\WinRAR\WinRAR.exe"
SET WINRARCMD=%WINRAR% a -u -r -esh

REM If nothing is supplied on the command line, do the workload from USERS
IF "%1" == "" FOR %%f in (%USERS%) DO CALL %0 %%f
REM If nothing is supplied on the command line, exit
IF "%1" == "" GOTO :EOF

REM Do all the files (only) in the root directory
ECHO Getting files in %USERDIR%
FOR %%f in (%USERDIR%\*.*) DO %WINRARCMD% "%DESTRAR%" "%%f"

ECHO Getting directories in %USERDIR%
REM Do all the directories which are visible
FOR /D %%f in (%USERDIR%\*) DO %WINRARCMD% "%DESTRAR%" "%%f\*.*"

ECHO Getting E-mail dir
%WINRARCMD% "%DESTRAR%" "%USERDIR%\E-mail\*.*"

:EOF
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question