How to skip "Access Denied" Folder when zip folder with command-line? - command-line

I have a batch file to copy data between 2 Disk below:
"C:\Program Files (x86)\WinRAR\WinRAR.exe" a -ag E:\Backup C:\NeedBackup -ms
Maybe use Winrar or 7-zip but they cannot copy folder with Deny for all permission. I want to skip that folder and continue to copy other files.
Anyone help me???

Start WinRAR and click in menu Help on Help topics. On tab Contents open list item Command line mode. Read first the help page Command line syntax.
Next open sublist item Switches and click on item Alphabetic switches list. While reading the list of available switches for GUI version of WinRAR build the command line.
For example:
"%ProgramFiles(x86)%\WinRAR\WinRAR.exe" a -ac -agYYYY-MM-DD -cfg- -ep1 -ibck -inul E:\Backup C:\NeedBackup\
Note 1: Switch -inul implicitly enables -y which is not documented but I know from author of WinRAR and my own tests.
You might use also the switch -dh although I recommend not using it for this backup operation.
By using additionally switch -ao the created backup archive would contain only files with having currently archive attribute set. This means only files added/modified since last backup are added to new archive because of usage of switch -ac in previous backup operation, i.e. creating incremental backup archives instead of always complete backups.
Well, the switch -df could be also used instead of -ac and -ao to create incremental backups. WinRAR deletes only files which could be 100% successfully compressed into the archive.
For details on those switches read their help pages.
Note 2: The command line creates a RAR archive file. For a ZIP file you would need additionally the switch -afzip.
Note 3: 7-Zip has also a help file explaining in detail also the usage from command line with all available commands and switches.

Related

Monitor directory for files and issue wget command?

I have an wget command running, but due to the website it regularly downloads "fake data". So, I am now downloading it dozens of times to get the correct content.
I now want the following:
use the wget command
check if in that directory are files <100kB
if yes ->use robocopy to save the >100kB files to another folder; repeat with wget
if no -> stop
I have the wget command and the robocopy command.
I only need now the function to check if an directory has a file <100kB and how to put this together into an cmd/powershell/bat or whatever.
How would the command for that look like? I have especially no idea how to check the files.

Batch file to archive important files into a zip file in Windows 7

I have some files which I would like to be able to archive daily into a zip file that has the date in the filename.
The files to be archived are in one folder, let's call them a, b and c.
I would like them to be zipped into a file with the name archiveYYYYMMDD.zip into a second (different) folder where YYYYMMDD is the current date. I'm struggling to come up with a suitable batch file.
I'm running Windows 7 x64 Ultimate. I have a scheduling program which would run the batch file at a preset time every day.
Thanks
Alan
This can be done with shareware archiver WinRAR with a single command line:
"%ProgramFiles%\WinRAR\WinRAR.exe" a -afzip -agYYYYMMDD -cfg- -ed -ep1 -ibck -inul -m5 -r -y -- "Path to Backup Folder\Backup_.zip" "Path to Folder to Backup\"
This single command line can be executed directly as scheduled task. There is no need for a batch file.
The help of WinRAR opened by starting WinRAR and clicking in menu Help on menu item Help topics explains under Contents menu item Command line mode the command line syntax, the command a and the used switches.

How to create mask in winrar to archive folders by name?

I have folders C:\testA01, C:\testA02 and C:\testB01, C:\testB02.
How to create a command to archive only folders with testA in their name?
"C:\Program Files\WinRAR\WinRAR.exe" a -r -u -rr8 -y C:\BACKUP\backup.rar C:\testA ?? \*.*
Windows command line interpreter does not support wildcards in folder paths. It is only possible to search for folders matching a pattern with DIR or FOR.
But take a look on text file WhatsNew.txt in program files directory of WinRAR version 5.30 or any later version. There can be read:
Folder wildcards are allowed in RAR command line in file names to
archive. For example:
rar a backup c:\backup\2015*\*
will archive all '2015*' folders in c:\backup. Use -r switch to search
for '2015*' also in c:\backup subfolders.
WinRAR v5.30 can be used on Windows XP and later Windows.
A command line for your backup task is for example:
"%ProgramFiles%\WinRAR\Rar.exe" u -cfg- -ep1 -idq -r -rr8 -y C:\BACKUP\backup.rar C:\testA*\*
For details on the used command u which is like command a with switch -u and the used switches see text file Rar.txt being the manual for the console version Rar.exe of WinRAR.
Of course you can also run from command line the GUI version, but one switch must be changed:
"%ProgramFiles%\WinRAR\WinRAR.exe" u -cfg- -ep1 -ibck -r -rr8 -y C:\BACKUP\backup.rar C:\testA*\*
The switch -ibck for running GUI version in background (minimized to system tray) is used instead of -idq which means for console version to run in quiet mode with only error messages printed into console window.
The commands and switches for the GUI version with some differences to console version are explained in help of WinRAR. Start WinRAR, click in menu Help on menu item Help topics, select tab Contents, open item Command line mode and read the pages listed below this list item.

Winrar CommandLine & Powershell : Exclude Full Directory Path Structure

Suppose I have a directory structure like
C:\Users\Desktop\abc\d
I want to rar archive the abc folder so that the structure of rar is:
abc\d
When I try using powershell to archive, winrar replicates the full path inside the archive, like:
\Users\Desktop\abc\d
I dont want the full path to be created inside the archive
Here's the script:
https://gist.github.com/saurabhwahile/50f1091fb29c2bb327b7
What am I doing wrong?
Use the command line:
Rar.exe a -r -ep1 Test.rar "C:\Users\Desktop\abc"
Rar.exe is the console version of WinRAR stored in same directory as WinRAR.exe. You can use this command line also with WinRAR.exe if you want to see the compression process in a graphic window.
a is the command and means add files to archive.
-r is a switch to recursively add all files and subdirectories including empty subdirectories to the archive.
-ep1 is another switch which results in execluding base directory.
For this command line the base directory is "C:\Users\Desktop\" and therefore the created archive Test.rar contains only abc and all files and subdirectories in directory abc which is what you want.
One more hint: Using the command line
Rar.exe a -r -ep1 Test.rar "C:\Users\Desktop\abc\"
results in adding all files and subdirectories of directory abc to the archive, but without directory name abc being also stored in the archive. The backslash at end makes this difference.
In other words: On using switch -ep1 everything up to last backslash in file/directory specification is not added to the archive.
For more information about available switches see the text file Rar.txt in the program files directory of WinRAR.

How do I silently install a 7-zip self-extracting archive to a specific directory?

The Ruby Devkit is a 7-zip based self-extracting archive.
I would like to invoke it silently without having to install 7-Zip to extract the files to a folder of my choosing, so that I can script the installation. I imagine it to be something like:
cmd> DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe /silent /dir="C:\DevKit"
But that, of course, doesn't work. What command line flags must I use to silently extract this archive into a folder of my choice?
try this:
C:\> DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe -o"C:\DevKit" -y
Update 2017: The tool from 7zsfx.info is now dead and gone.
Original, old post from 08-2015:
If you are trying to extract an 7zip SFX (http://7zsfx.info/) archive:
sfx.exe -y -gm2 -InstallPath="C:\\your\\target\\path"
Switches Docu
-y hide some prompts
-gm2 hides the extraction dialog completely (silent mode)
-InstallPath sets the target path (you need double backslashes)
7z SFX Guide
The official way to create a SFX package is to use -sfx[{name}] : Create SFX archive.
And that means the created SFX packages uses two kinds of CLI options:
official CLI options from 7zSFX, and
the passed through options you configured in your config, before creating the package.
You can think of it as parameter forwarding to the packaged executable. This parameter forwarding depends on the SetEnvironment and RunProgramm configuration!
The full process:
Create archive Package.7z:
containing Installer.msi and additional crap.cab file.
Create config file config.txt:
;!#Install#!UTF-8!
Title="Installation"
SetEnvironment="strInstall=hidcon:Installer.msi /qn"
RunProgram="%strInstall%"
;!#InstallEnd#!
Now we generate Test.exe by combining sfx+config+archive into an executable.
copy /b 7zS.sfx + config.txt + Package.7z SfxInstaller.exe
Note: 7zS.sfx is from the official 7zip extra package.
Now, when you run SfxInstaller.exe you can pass for instance /lv InstallerLog.txt to create a install log, e.g.
SfxInstaller.exe /lv InstallerLog.txt
Since 7-zip is used, simply create a self-extracting archive in .exe. and run it with switches -o and -y.
I use it to save space on USB drive. For instance, I run VDiskAir application infrequently. I create a self-extracting archive of the VDiskAir program folder (about 15MB):
7z a -SFX -mx9 VDiskAir.exe [VDiskAir folder path]
NB: -mx9 is used here to maximise compression.
I create a DOS BAT to run the self-extracting VDiskAir.exe (about 5MB) created, save it as VDiskAir.bat containing:
VDiskAir.exe -o%TMP% -y
%TMP%\VDiskAir\VDisk_Air.exe
I'm not worried that the VDiskAir folder (in %TMP% extracted with VDiskAir program files) is undeleted after running VDiskAir this way, since I have a BAT script to clear %TMP% on shutting down/starting up.
Below is what I use for Autodesk product:
Start /W %~dp0AutoCAD_2018_French_LP_Win_64bit_dlm.sfx.exe -suppresslaunch -d C:\Autodesk