Page 1 of 2
how do i split and join files?
Posted: 08 Mar 2012 02:05
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

Re: how do i split and join files?
Posted: 08 Mar 2012 02:33
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?
Re: how do i split and join files?
Posted: 08 Mar 2012 06:18
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.
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.
Re: how do i split and join files?
Posted: 08 Mar 2012 14:20
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.
Re: how do i split and join files?
Posted: 10 Mar 2012 14:36
by neutrox
help anyone?
Re: how do i split and join files?
Posted: 10 Mar 2012 14:38
by admin
What error are you getting after doing what?
Re: how do i split and join files?
Posted: 10 Mar 2012 14:43
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.
Re: how do i split and join files?
Posted: 10 Mar 2012 14:49
by neutrox
Error happens reading .txt files too!
Re: how do i split and join files?
Posted: 10 Mar 2012 15:04
by admin
after doing what?
Re: how do i split and join files?
Posted: 10 Mar 2012 18:28
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
Re: how do i split and join files?
Posted: 10 Mar 2012 23:04
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.
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.

wish: SC writefile should have a parameter through which we could directly control the increment format in case of collision.
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!";
Re: how do i split and join files?
Posted: 11 Mar 2012 02:36
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.
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.
Re: how do i split and join files?
Posted: 11 Mar 2012 05:43
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.
Re: how do i split and join files?
Posted: 11 Mar 2012 10:16
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.:
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...)
Re: how do i split and join files?
Posted: 11 Mar 2012 13:28
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.
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.
