I am using the following command in a batch file in order to archive MY_LARGE_FOLDER and my .rar file is too big:
WinRAR a -r D:\MY_LARGE_FOLDER.rar D:\MY_LARGE_FOLDER\*.txt D:\MY_LARGE_FOLDER\
How can I archive MY_LARGE_FOLDER, into small .rar files of 4MB each using batch file?
(or in other words, How to use the "Split to volumes, bytes" option using batch file?)
Thanks.
Thanks for the help!
I used the -v switch:
WinRAR a -r **-v4000** D:\MY_LARGE_FOLDER.rar D:\MY_LARGE_FOLDER\*.txt D:\MY_LARGE_FOLDER\
and I got now 4 files of 4000 bytes each but after opening some of the files I saw that the files are duplicated on more than one archive (e.g. on Part01.rar and on Part02.rar) ???
1. I also tried the -s (solid) switch and the result is the same?
How can I solve it?
There are two "manuals" installed with WinRAR:
The help file WinRAR.chm which has on tab Contents the item Command line mode with the subitem Switches with a link to page Switch -V<n>[k|b|f|m|M|g|G] - create volumes, and
the text file Rar.txt in program files folder of WinRAR which is the manual for console version Rar.exe. It contains nearly the same information as the help file regarding the available switches and their explanation.
I suggest to use in a batch file the console version with the command line:
"%ProgramFiles%\WinRAR\Rar.exe" a -cfg- -ep1 -idcdp -m5 -md4m -r -s -v4M "D:\MY_LARGE_FOLDER.rar" "D:\MY_LARGE_FOLDER\"
Console application Rar.exe compresses D:\MY_LARGE_FOLDER\ with all files and subfolders with folder name MY_LARGE_FOLDER included into an archive with nearly no output to console window using best compression creating a multivolumne solid archive with 4 MB dictionary size (in case of lots of small *.txt files) and 4 MB per archive file (volume).
There can be used alternatively:
"%ProgramFiles%\WinRAR\Rar.exe" a -cfg- -ep1 -inul -m5 -md4m -r -s -v4M "D:\MY_LARGE_FOLDER.rar" "D:\MY_LARGE_FOLDER"
That creates nearly same archive with the difference that folder name MY_LARGE_FOLDER is not included in the archive (backslash at end removed) and no message written to console window (-inul instead of -idcdp).
My solution for 20Mb volumes was:
"%ProgramFiles(x86)%\WinRAR.Rar.exe" a -cfg- -ep1 -idcdp -m5 -md4096 -r -s -v20M "C:\test.rar" "C:\test\"
Related
I am writing a script in Lua 5.1 for use with a game engine (EDGE).
I need my script to copy about 20 files into a .miz file (which is really a zipped folder with a set structure) and navigate that structure and copy those files in from a non-zipped folder on the hard drive.
Because Windows 11 it the future I need to use NanaZip rather than 7z which isn't W11 supported.
However, all the examples I've found are for using LUA to zip up files, not insert non-zipped files INTO a zip file without unzipping it.
Is this even possible?
Similar to #koyaanisqatsi I tried it with 7z. You didn't comment on our question on why 7z should be avoided nor whether you are even allowed to use os.execute, but it should provide a good starting point:
os.execute("7z a yourZip.zip yourFile.png")
Where a is the flag for Add.
See the manual for other flags like compression: https://linux.die.net/man/1/7z
Windows 11 also have tar that have the option r and u
D:\temp>tar h
tar(bsdtar): manipulate archive files
First option must be a mode specifier:
-c Create -r Add/Replace -t List -u Update -x Extract
Common Options:
-b # Use # 512-byte records per I/O block
-f <filename> Location of archive (default \\.\tape0)
-v Verbose
-w Interactive
Create: tar -c [options] [<file> | <dir> | #<archive> | -C <dir> ]
<file>, <dir> add these items to archive
-z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
--format {ustar|pax|cpio|shar} Select archive format
--exclude <pattern> Skip files that match pattern
-C <dir> Change to <dir> before processing remaining files
#<archive> Add entries from <archive> to output
List: tar -t [options] [<patterns>]
<patterns> If specified, list only entries that match
Extract: tar -x [options] [<patterns>]
<patterns> If specified, extract only entries that match
-k Keep (don't overwrite) existing files
-m Don't restore modification times
-O Write entries to stdout, don't restore to disk
-p Restore permissions (including ACLs, owner, file flags)
bsdtar 3.5.2 - libarchive 3.5.2 zlib/1.2.5.f-ipp bz2lib/1.0.6
( Above cmd.exe was opened from Lua with: os.execute('cmd') )
You can extract a ZIP with it but not creating one as far as i know.
(tar -xf archive.zip)
But is it a Problem for you to use TAR instead of ZIP?
I would like to use batch and winrar to compress certain files and save them as .scs.
The whole thing just doesn't want to work at the end.
Manually see it from the settings:
The batch code looks like this:
rar a -m0 -ep -u -x "finkenwerder.scs" def map material**.
It almost fits the file size, but when I let the file run in the game, it tells me it doesn't work.
If I complete it manually, the file will work.
I am unsure of whether you need to actually include the folders to the archive or not, so here are 2 solutions. Firstly -x switch is not needed as you are not excluding files.
If you need to include the folders, then use this method. Also please include the full paths to your directories instead as it ensure you do not have issues with paths.
rar a -m0 -u "C:\path\to\file\finkenwerder.scs" "C:\game\def" "C:\game\map" "C:\game\material"
if you need only the files, and not the directories map def and material then do this
rar a -m0 -ep -u "C:\path\to\file\finkenwerder.scs" "C:\game\def" "C:\game\map" "C:\game\material"
lastly, you can also run the switches via batch, but using the GUI WinRAR using the same method as above.
"C:\Program Files\WinRAR\winrar" a -m0 -u "C:\path\to\file\finkenwerder.scs" "C:\game\def" "C:\game\map" "C:\game\material"
or
"C:\Program Files\WinRAR\WinRAR" a -m0 -ep -u "C:\path\to\file\finkenwerder.scs" "C:\game\def" "C:\game\map" "C:\game\material"
So easy and cool batch question. Sorry for this ultimate newbie question !
I've a folder which contains hundreds of videos like that:
Video001 - Introduction.avi
Video002 - History of Stack Overflow.avi
Video003 - Before Asking.avi
...
Video999 - Conclusion.avi
I need re-encode all of them with x264 codec. Ffmpeg is very slow so I tried to use HandBrake. There is a command line edition of HB and great default presents. I could write this command for converting only one file with "Normal" present:
HandBrakeCLI.exe -i "Video001 - Introduction.avi" -o "Video001 - Introduction.mp4" -Z Normal
My question: How can I convert all of them in folder and delete after conversion process? Thank you!
Note: If you think ffmpeg is better solution I can give my fav present. Handbrake says about Normal present:
Normal: -e x264 -q 20.0 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 --loose-anamorphic --modulus 2 -m --x264-preset veryfast --h264-profile main --h264-level 4.0
for %%f in (*.avi) do (
handbrakecli.exe -i "%%~nxf" -o "%%~nf.mp4" -Z Normal
del "%%~f"
)
For each avi file, call handbrake with the name and extension of input file and generate an output file with the name of the original file and .mp4 extension
After a conversion process I've thousands files like so:
VideoFolderName0001 - Introduction
video
videostream.avi
audio
audiostream.mp3
VideoFolderName0002 - History of stackoverflow
video
videostream.avi
audio
audiostream.mp3
VideoFolderName003 - Before Asking
video
videostream.avi
audio
audiostream.mp3
How can we merge (or join or combine or mux ..etc) *.avi and *.mp3 files according to (up 2) foldername.
I tried with avidemux one by one. But you know it takes a long time. There should be a cool script to automate that.
At first, merge all files:
for /d %%a in (VideoFolderName*) do ffmpeg -i "%%~a\videostream.avi" -i "%%~a\audiostream.mp3" -c copy "%%~a\videofile.avi"
next build the concatenate file:
(for /d %%a in (VideoFolderName*) do echo(file '%%~a\\videofile.avi')>"concat.txt"
and last build the concatenated video:
ffmpeg -f concat -i concat.txt -c copy video.avi
You must take care for the correct sequence of the avi files to concatenate.
ffmpeg manual
Using Terminal and Shell/Bash commands is there a way to retrive specific files from a web directory? I.e.
Directory: www.site.com/samples/
copy all files ending in ".h" into a folder
The folder contains text files, and other files associated that are of no use.
Thanks :)
There are multiple ways of achieving this recursively:
1. using find
1.1 making directorys using find -p to create recursive folders without errors
cd path;
mkdir backup
find www.site.com/samples/ -type d -exec mkdir -p {} backup/{} \;
1.2 finding specific files and copying to backup folder -p to perserve permissions
find www.site.com/samples/ -name \*.h -exec cp -p {} backup/{} \;
Using tar well actually for reverse type of work i.e. to exclude specific files which the part of the question related to text files matches this answer more:
You can have as many excludes as you liked added on
tar --exclude=*.txt --exclude=*.filetype2 --exclude=*.filetype3 -cvzf site-backup.tar.gz www.site.com
mv www.site.com www.site.com.1
tar -xvzf site-backup.tar.gz
You can use the wget for that, but if there are no links to that files. I.e. they exist, but they are not referenced from any html page, then bruteforce is the only option.
cp -aiv /www.site.com/samples/*.h /somefolder/
http://linux.die.net/man/1/cp