Script Request - File-merging Tool.

Discuss and share scripts and script files...
Post Reply
Slavaon
Posts: 158
Joined: 29 Mar 2012 07:35

Script Request - File-merging Tool.

Post 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!

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Script Request - File-merging Tool.

Post 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.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Slavaon
Posts: 158
Joined: 29 Mar 2012 07:35

Re: Script Request - File-merging Tool.

Post by Slavaon »

SkyFrontier
Here - a direct link to the files
If possible, I'll be happy :)

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Script Request - File-merging Tool.

Post 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.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

highend
Posts: 14942
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Script Request - File-merging Tool.

Post 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...
One of my scripts helped you out? Please donate via Paypal

Slavaon
Posts: 158
Joined: 29 Mar 2012 07:35

Re: Script Request - File-merging Tool.

Post 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.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Script Request - File-merging Tool.

Post 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');

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Script Request - File-merging Tool.

Post 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...";
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Slavaon
Posts: 158
Joined: 29 Mar 2012 07:35

Re: Script Request - File-merging Tool.

Post by Slavaon »

SkyFrontier
Many thanks for your time and work.
But it's not something that I need.

Post Reply