Page 1 of 1

Script Request - File-merging Tool.

Posted: 14 Aug 2013 11:41
by Slavaon
Can someone please build a file merging tool.
I have a folder that has a single JPG file and many files RAR - 01.rar, 02.rar, 03.rar... I need to each file RAR join JPG file using the bat file:

Code: Select all

@echo off
if /I %~x1==%~x2 exit
if /I %~x1 NEQ .jpg (if /I %~x2 NEQ .jpg exit)
if /I %~x1 NEQ .rar (if /I %~x2 NEQ .rar exit)
if /I %~x1==.jpg (
copy /b %1+ %2 "%~d1%~p1%~n1.cbr"
) else (
copy /b %2+%1 "%~d2%~p2%~n2.cbr")
The possible sequence of steps:
-> select a jpg file and the first RAR\ run bat (<xypath>\Data\Scripts\cbr.bat)\ pause for join files\ update the list of files\ choose the first RAR\ delete\ update the list of files = we get 01.cdr.
Then move on to the next pair of files:
-> select a jpg file and the first RAR\ run bat (<xypath>\Data\Scripts\cbr.bat)\ pause...
I do not know much about scripts, is it possible?
Thanks!

Re: Script Request - File-merging Tool.

Posted: 14 Aug 2013 13:47
by SkyFrontier
If you can provide sample files I may give it a try.
Restfiles is an easy tool to upload with, or pm me for e-mail exchange.

Re: Script Request - File-merging Tool.

Posted: 14 Aug 2013 18:11
by Slavaon
SkyFrontier
Here - a direct link to the files
If possible, I'll be happy :)

Re: Script Request - File-merging Tool.

Posted: 14 Aug 2013 20:08
by SkyFrontier
First attempt gave me a bad taste on my mouth.
=)
Now I'm preparing for a travel, be back next monday/thursday - then I'll be ready for another take on this.
In the meantime, any one else feel free to reply to this request.
Yummy.

Re: Script Request - File-merging Tool.

Posted: 14 Aug 2013 20:41
by highend
In the meantime, any one else feel free to reply to this request.
I would but english is not my main language and I'm afraid I don't really get what the OP really want's to achieve...

Re: Script Request - File-merging Tool.

Posted: 14 Aug 2013 21:33
by Slavaon
highend
I know that you are a good person. Here - helped SkyFrontier.
Combine your efforts and help me.
My gratitude will not know borders.

Re: Script Request - File-merging Tool.

Posted: 14 Aug 2013 22:23
by TheQwerty
highend wrote:
In the meantime, any one else feel free to reply to this request.
I would but english is not my main language and I'm afraid I don't really get what the OP really want's to achieve...
I believe the goal is to just merge the binary data of the two files, jpg-first, with the end goal actually being to take advantage of the file formats to "hide" the rar file "within" the jpg.

I don't have the time right now to write all of the code to support this but getting it down to something like this should be all that's needed:

Code: Select all

WriteFile('combined.jpg', ReadFile('image.jpg', 'b') . ReadFile('archive.rar', 'b'), 'r', 'b');

Re: Script Request - File-merging Tool.

Posted: 23 Aug 2013 19:15
by SkyFrontier
*I REALLY DOUBT* this is going to work.
Anyway, it's
-unpacking .rar,
-reading file as BINARY,
-writing the info regardless of any header info,
-cleaning temp remainders.
To do:
icons, better captions, smart checking on eventual user errors.

If anyone has a better idea or other inputs for this, please do so - I can't even find the time to produce test files myself and those provided by Slavaon find no support on my machine.

@Slavaon: is DSC_6328.jpg a converted file from all those .xmp?
Sizes:
700.877 bytes: DSC_6328.jpg
105.956 bytes: 17 .xmp
105.956 bytes: combined .xmp (so they're combined de facto!, and I'd bet all those headers combined are damaging the resulting file. But, can't say for sure...)

Sorry for so very late reply. Being very busy lately. I mean: *VERY!* :evil:

Code: Select all

"rar"
   $ext = ".xmp"; // WITH dot!
   $exe = get("regcmd", "rar");
// step;
   $getx = gettoken($exe, -2, ".", 2);
   $getx = gettoken($getx, 2, "=");
   $exe = trim($getx, '"');
   $exe = trim($exe, ' ');
   $exe = "$exe" . ".exe";

   $a = get(selecteditemspathnames);
   foreach($tk, "$a", "<crlf>") {
// step;
   focus;
   $nm = getpathcomponent("$tk", base);

   $tk2 = quote("$tk");

   run "$exe" "x" $tk2, , 2;

   $b = readfile("$nm" . "$ext", b);
// step;
   writefile("NewFile" . "$ext", "$b", a, b);
// step;
   delete 1, 0, "<curpath>\" . "$nm" . "$ext";
   status "done: $nm...";


                                }

   echo "all done, anyway...";
"non-rar"
   $a = get(selecteditemspathnames);
   foreach($tk, "$a", "<crlf>") {
// step;
   focus;
   $nm = getpathcomponent("$tk", base);
   $ext = getpathcomponent("$tk", ext);

   $b = readfile("$tk", b);
// step;
   writefile("NewFile." . "$ext", "$b", a, b);

   status "done: $nm...";


                                }

   echo "all done, anyway...";

Re: Script Request - File-merging Tool.

Posted: 25 Aug 2013 07:02
by Slavaon
SkyFrontier
Many thanks for your time and work.
But it's not something that I need.