Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
zagix
- Posts: 68
- Joined: 16 Oct 2013 23:19
#1
Post
by zagix » 25 Mar 2014 22:46
Hi,
I want to skip/exempt a folder when creating rar files from c:\Database to my destination folder.
Folder to exempt named Local
Code: Select all
@echo off
pushd C:\Database
For /F "delims=" %%G IN ('dir /ad /b') do (
pushd "%%G"
For /F "delims=" %%H IN ('dir /ad /b ^| find /V "Archived"') do (
"C:\Program Files\WinRAR\Rar" a -r "F:\BackupMarch\%%H.rar" "%%H"
)
POPD
)
popd
-
Compo
- Posts: 600
- Joined: 21 Mar 2014 08:50
#3
Post
by Compo » 26 Mar 2014 03:27
Since the directory you are wishing to exclude is named Archived, then I'd suggest that it and its contents have the archive attribute set. With that set you would find it easier to exclude from your operations, (I would certainly expect an exclude specific attribute switch in your archiving/compression software).
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 26 Mar 2014 05:03
I know Winzip has an exclusion switch. Has for over 10 years. I would look at the switches for RAR.exe and see if there is an option for that.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#5
Post
by foxidrive » 26 Mar 2014 06:10
This change below will exclude the local folder as well as the archived folder.
findstr /i /b /e /V "Archived local"Code: Select all
@echo off
pushd C:\Database
For /F "delims=" %%G IN ('dir /ad /b') do (
pushd "%%G"
For /F "delims=" %%H IN ('dir /ad /b ^| findstr /i /b /e /V "Archived local"') do (
"C:\Program Files\WinRAR\Rar" a -r "F:\BackupMarch\%%H.rar" "%%H"
)
POPD
)
popd
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#6
Post
by Squashman » 26 Mar 2014 06:24
I just looked at the documentation and RAR does have a -x switch just like Winzip.
-
Compo
- Posts: 600
- Joined: 21 Mar 2014 08:50
#8
Post
by Compo » 26 Mar 2014 09:00
I couldn't dispute the -X switch existing since I do not use the program nor it's manual, but I got the impression from a quick web search that perhaps that switch only exists or existed in some version(s). [/i]It would be ridiculous to not have such a feature however.[/i]
-
carmine
- Posts: 15
- Joined: 18 Nov 2013 13:12
#9
Post
by carmine » 26 Mar 2014 16:08
Hi,
Thanks to all for supporting.
The -x switch in my case works.
Thanks a lot.