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"
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 have in a folder, pairs of files, mp4 and srt subtitle files.
e.g.
video1.mp4
video1.srt
video2.mp4
video2.srt
I want to prepend a random number to each video file but I must also prepend the same number to the set file.
Does anyone know how I can do this?
I'm using a mac, so it could be a bash script, automator, or even PowerShell.
I worked it out. Here's a single line bash command that does what I need.
for f in *.mp4 *.m4v; do ran=$(printf "%03.0f" $((RANDOM%300))); myFile="${f}"; mv -f "${myFile}" "${ran}-${myFile}"; mv -f "${myFile%.*}.srt" "${ran}-${myFile%.*}.srt"; done
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\"
I'm trying to write a .bat script as the pre-commit hooks in svn. However when I was trying to use the svnlook cat command with the -t option, it's not working. It kept telling me syntax errors. I tried everything including adding quotes, changing the -t option etc. However, if I remove the -t option, it doesn't report syntax errors.
So this is the error scripts:
SET REPOS=%~1 (I want to remove the quotes of the path)
SET TXN=%2
"C:\Program Files (x86)\VisualSVN Server\bin\svnlook.exe" cat -t %TXN% %REPOS% myworkingdir/txtIwanttoread
If I do the following, they are all fine:
SET REPOS=%~1 (I want to remove the quotes of the path)
SET TXN=%2
"C:\Program Files (x86)\VisualSVN Server\bin\svnlook.exe" cat %REPOS% myworkingdir/txtIwanttoread
OR
SET REPOS=%~1 (I want to remove the quotes of the path)
SET TXN=%2
"C:\Program Files (x86)\VisualSVN Server\bin\svnlook.exe" cat -r 28 %REPOS% myworkingdir/txtIwanttoread
Somebody please help me!! Thanks!
Never mind everybody, I think I just figured it out myself. We should use SET TXN=%~2 to eliminate the quotes. Also even if I did that, the stupid batch puts a space at the end of the variable TXN. This is what causes the problem. So the script should look like:
SET REPOS=%~1 (I want to remove the quotes of the path)
SET TXN=%~2
SET TXN=%TXN: =% (deblank)
"C:\Program Files (x86)\VisualSVN Server\bin\svnlook.exe" cat -t %TXN% %REPOS% myworkingdir/txtIwanttoread
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