Hello,
I want to Archive the folders with WinRAR the folder layout is like this.
C:\Data\Company\<folder1>
C:\Data\Company\<folder2>
& more
I want to archive this sub-folders to a new folder named Archived in C:\Data\Company with individual folders archived inside it.
C:\Data\Company\Archived\folder1.rar
C:\Data\Company\Archived\folder2.rar
Archive Folders Winrar
Moderator: DosItHelp
Re: Archive Folders Winrar
I don't have Winrar so you will have to supply that command.
I don't know the command line switches but it should look something like
rar a -r "..\Archived\%%H.rar" "%%H"
Code: Select all
@echo off
pushd C:\Data
For /F "delims=" %%G IN ('dir /ad /b') do (
pushd "%%G"
For /F "delims=" %%H IN ('dir /ad /b ^| find /V "Archived"') do (
winrar command here. %%H will be the folder you want to backup.
)
)
I don't know the command line switches but it should look something like
rar a -r "..\Archived\%%H.rar" "%%H"
Re: Archive Folders Winrar
Hi,
Thanks squashman for reply, But this codes compress the folder and sub-folders to Archived folder, instead of this i wanted to have the individual sub-folders to get archived and saved to Archived.
Like this:
C:\Data\Company\Archived\folder1.rar
C:\Data\Company\Archived\folder2.rar
Thanks squashman for reply, But this codes compress the folder and sub-folders to Archived folder, instead of this i wanted to have the individual sub-folders to get archived and saved to Archived.
Like this:
C:\Data\Company\Archived\folder1.rar
C:\Data\Company\Archived\folder2.rar
Re: Archive Folders Winrar
Like I said. I don't use Winrar and I don't have Winrar. You will have to lookup the correct syntax for the Winrar command.
If you can tell me what is ending up in the Archived Folder I might be able to help you troubleshoot it but without seeing what the script is outputting I really can't do much for you.
If you can tell me what is ending up in the Archived Folder I might be able to help you troubleshoot it but without seeing what the script is outputting I really can't do much for you.
Re: Archive Folders Winrar
Ok. My fault. I forgot the POPD.
I also changed the RAR command to use the absolute path instead of the relative path.
I also changed the RAR command to use the absolute path instead of the relative path.
Code: Select all
@echo off
pushd C:\Data
For /F "delims=" %%G IN ('dir /ad /b') do (
pushd "%%G"
For /F "delims=" %%H IN ('dir /ad /b ^| find /V "Archived"') do (
rar a -r "%%~dpHArchived\%%H.rar" "%%H"
)
POPD
)
popd
Re: Archive Folders Winrar
Hi,
Thanks Squashman. Its working.
Thanks
Thanks Squashman. Its working.
Thanks
Re: Archive Folders Winrar
Hi,
Sorry to restart the thread.
I need a small change if its possible the newly created .rar files are created and saved at C:\Data\Archived
instead be created & saved at D:\Backup\data.
I will be highly thankful.
Thanks
Sorry to restart the thread.
I need a small change if its possible the newly created .rar files are created and saved at C:\Data\Archived
instead be created & saved at D:\Backup\data.
I will be highly thankful.
Thanks
Re: Archive Folders Winrar
Well this tells me you took the fish and didn't bother to learn how to fish. If you understand the syntax of the winrar command you should know what to change in that one line of code. At least make an attempt.