how do i split and join files?

Discuss and share scripts and script files...
neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

how do i split and join files?

Post by neutrox »

I saw a beta post which was reading on "easily split and join files" but i'm still wondering how?

the only thing i get is an error after reading some ~200 MB rtf files :|

nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: how do i split and join files?

Post by nas8e9 »

neutrox wrote:I saw a beta post which was reading on "easily split and join files" but i'm still wondering how?
AFAIK XYplorer doesn't support this, although it may be possible through scripting. Where did you read this?

This thread has more information about split and join.
neutrox wrote:the only thing i get is an error after reading some ~200 MB rtf files :|
I'm not sure what you're doing here and whether it relates to your first question. Could you post your steps to reproduce as well as your XYplorer (including Home or Pro edition) and Windows version?

neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

Re: how do i split and join files?

Post by neutrox »

took a time to recall but here it is.

I even made a search and repalcement table so .rtf formatting as source won't be a problem.

my first attempts to understand the readfile command led me to conclude that there must be a bug somewhere. I am not posting from the test machine as this one may not suffice, but here are some specs:
windows 7 home, 8 GB / ram, xyplorer pro trial 10.90.0002

problem doesn't happen on smaller files, ~80/90/100 MB. :roll:

any way I can determine a folder size using script'ing? I may be overlooking sthg here... :|
v10.90.0002 - 2012-03-03 20:27
+ Scripting got a new function.
Name: FileSize
Action: Retrieves the size of the specified file, in bytes.
Syntax: filesize([filename])
filename: file full path/name, or relative to current path
defaults to the current file
Examples:
echo filesize();
echo filesize("C:\WINDOWS\explorer.exe");
+ SC ReadFile enhanced by new Start parameter.
Name: ReadFile
Action: Read data from file into string.
Syntax: readfile([filename], [mode], [numbytes], [codepage], _
[start=1])
start: byte position to start reading from; 1 = beginning of file
Example:
// read current file from position 100
text readfile(, , , , 100);
Tip: Now with FileSize() and ReadFile(..., start) you can easily
write scripts that join and split files.

nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: how do i split and join files?

Post by nas8e9 »

@neutrox: The developer will know, but it may be to do with your dataset being too large.

As for getting the size of a folder, the report scripting command should help here.

neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

Re: how do i split and join files?

Post by neutrox »

help anyone?

admin
Site Admin
Posts: 66252
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: how do i split and join files?

Post by admin »

What error are you getting after doing what?

neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

Re: how do i split and join files?

Post by neutrox »

A popup windows which reads a message on insufficient memory. but I do have enough memory!

And i'd really like a script to split / join files as mentioned.

neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

Re: how do i split and join files?

Post by neutrox »

Error happens reading .txt files too!

admin
Site Admin
Posts: 66252
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: how do i split and join files?

Post by admin »

after doing what?

neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

Re: how do i split and join files?

Post by neutrox »

Attached a screenshot.

the problem is random, but heavier files like the one i did (166 MB) are prone to pop the error.

after doing this on adrees bar for instance:

Code: Select all

status wait...; $file = readfile(<curitem>); echo "done!";
note: png was not allowed, added jpg.

note 2: not allowed again. window reads: error 14(0...0E), desc: out of string space, dll: 0, proc: script_proccess

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: how do i split and join files?

Post by tiago »

Here goes your script but some notes first:

1. SC readfile won't stop if numbytes value exceeds the remaining data to be read, thus generating files which are multiples of numbytes. This issue is fixed in my script.

2. :arrow: bug warning :!: SC writefile won't properly write unicode files as it completely loses formating when writing portions which contain unicode text.

3. there are a few text merging scripts posted on forum and I think they'll suffice re. the join files part of your wish. Take a look and write back in case if not.

4. i confirm the problem with SC readfile reporting errors on large files. Tested on 500 MB, 1+ GB files, though.

5. :idea: wish: SC writefile should have a parameter through which we could directly control the increment format in case of collision. :roll:

Code: Select all

      end(compare("<xyver>", '10.90.0002', 'v') < 0, "Written for XYplorer v10.90.0002+.");
      end(getinfo("CountSelected") < 1), "Pick a file first!";

      $file = "<curitem>";
      $basenm = regexreplace($file, ".+\\(.+)\..*", "$1");
      $tdir = regexreplace($file,  "(.+\\).+", "$1");
      $ext = regexreplace($file, ".+\.(.*)", "$1");

      $max = filesize($file);
      $read = 500000; //amount which will be read; user def; default: 100.000 bytes (x 10 = 1 MB)

      $factor = $max \ $read;
      $factorF = $factor * $read;
      $mod = $max - $factorF;

      $incr = 1; //starting amount; FIXED

      WHILE ($incr < $factorF)                   {
      $data = readfile(, , $read, , $incr);
      $incr = $incr + $read;

      writefile ("$tdir" . "$basenm" . " - Splitted." . "$ext", $data, r);
                                                 }

      $data = readfile(, , $mod, , $incr);
      writefile ("$tdir" . "$basenm" . " - Splitted." . "$ext", $data, r);

      echo "file splitted!";
Last edited by tiago on 12 Mar 2012 01:10, edited 1 time in total.
Power-hungry user!!!

neutrox
Posts: 194
Joined: 05 Mar 2012 15:23

Re: how do i split and join files?

Post by neutrox »

still in the a-b-cs so I just couldn't do without a help. thanks much! Joining those files again were easy, but i noticed that sometimes (sometimes not!) the fractioned words will rejoin with repeated letters. Problem is in the splitting code as "support" splits as "suppo" and "ort" then rejoins evidently as "suppoort". Must investigate. :roll:

And yes I see that unicode source files are not correctly transcribed, writing 's e p a r a t e d' letters like when you open .reg files on old machines using notepad. broken unicode support is my guess.

as another test I first ran your script on a ~ 150 MB file (.txt!) using a fresh started desktop and the problem was shown.

Twisten
Posts: 204
Joined: 27 Apr 2008 10:30

Re: how do i split and join files?

Post by Twisten »

Mmm, even though you store the info into a supposed 'string' variable the read and write function seem to treat the file as binary from the function description/usage, so maybe the catch is between the return of the data and storage in the variable.

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: how do i split and join files?

Post by PeterH »

The code contains:

Code: Select all

      $incr = "0"; //starting amount; FIXED

      WHILE ($incr < $factorF)                   {
      $data = readfile(, , $read, , $incr);
      ...
readfile() documents:

Code: Select all

start   byte position to start reading from;
        1 = beginning of file 
So I think $incr should be initialized to 1.
This will be the reason for the doubled bytes reported by neutrox?

By the way: 0 or 1 are numbers: no need to define them quoted. I.e.:

Code: Select all

    $incr = 1;
And: you use automatic detecting of unicode files. I think it could be possible that the detection differs for parts of file with and without unicode? (Just a guess...)

admin
Site Admin
Posts: 66252
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: how do i split and join files?

Post by admin »

tiago wrote:Here goes your script but some notes first:

1. SC readfile won't stop if numbytes value exceeds the remaining data to be read, thus generating files which are multiples of numbytes. This issue is fixed in my script.

2. :arrow: bug warning :!: SC writefile won't properly write unicode files as it completely loses formating when writing portions which contain unicode text.
Both nonsense. I stopped reading further. :evil:

Post Reply