Request: merge files in one + make paths as title of parts

Discuss and share scripts and script files...
Post Reply
DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Request: merge files in one + make paths as title of parts

Post by DmFedorov »

Complexity consists not only in that, that between parts of the file surely must be path to this part, complexity still consists in that, that I should make the return action: divide the file again into parts which were before assembly.

Such file is necessary to me for translation of FireFox, SeaMonkey and similar browsers, where offered to make the translation from 300 to 600 files.
(There is no problem to get a list of files in file pane of XYplorer, for such script)

PS: Of course if I have only one file I can do the translation in a special program where there are filters, comments, etc.
One file will allow me to compare translation of different programs and identify the differences.
In general, it will help solve the problem of poor translation.

I thank in advance those who will try to solve this perhaps difficult but interesting task.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Request: merge files in one + make paths as title of par

Post by highend »

Sorry, either your english is .... or my english is .... However... Why don't you provide a few real world examples (before -> after) to make clear what you need (because I have no clue what that is)?
One of my scripts helped you out? Please donate via Paypal

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: Request: merge files in one + make paths as title of par

Post by DmFedorov »

Of course my English is wrong. But I honestly don't know when you did not understand. This is the problem.
Example:

Before:

Code: Select all

bla-bla\locale
. \branding
. .    brand.dtd; 	1 КБ;
. .    brand.properties; 	1 КБ;
. .    browserconfig.properties; 	1 КБ;
. \browser
. .    aboutCertError.dtd; 	3 КБ;
. .    aboutDialog.dtd; 	8 КБ;
. .    aboutHealthReport.dtd; 	1 КБ;
After (one file: Content):

Code: Select all

[bla-bla\locale\branding\brand.dtd]
    Content of file
[bla-bla\locale\branding\brand.dtd]
    Content of file
[bla-bla\locale\branding\brand.properties]
    Content of file
[bla-bla\locale\branding\browserconfig.properties]
    Content of file
[bla-bla\locale\browser\aboutCertError.dtd]
    Content of file
[bla-bla\locale\browser\aboutDialog.dtd]
    Content of file
[bla-bla\locale\browser\aboutHealthReport.dtd]
    Content of file
Of course indent before "Content of file" here only for clarity.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Request: merge files in one + make paths as title of par

Post by highend »

So you want the script to gather all / a few files from a specific folder and put the contents of all these files into a new file?

If that's true:
- Do you select the source files manually?
- Or do you want the script ask you to navigate to a folder and then it collects all files recursively from there?
- Are there any files that must be filtered out (because their content shouldn't go into the new file)?
- What's the name and the path for the new file? Same folder where you navigated to / or <curpath>
One of my scripts helped you out? Please donate via Paypal

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: Request: merge files in one + make paths as title of par

Post by DmFedorov »

highend wrote:So you want the script to gather all / a few files from a specific folder and put the contents of all these files into a new file?

If that's true:
- Do you select the source files manually?
- Or do you want the script ask you to navigate to a folder and then it collects all files recursively from there?
- Are there any files that must be filtered out (because their content shouldn't go into the new file)?
- What's the name and the path for the new file? Same folder where you navigated to / or <curpath>
I want to use file-pane with "Branch view" and visual Filter.
Is that possible?
---What's the name and the path for the new file?
any (in first parent path)

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Request: merge files in one + make paths as title of par

Post by highend »

So you're selecting all files manually in the branch view...

Code: Select all

    $targetFile = "<curpath>\NewTranslation.txt";

    $contents = "";
    foreach($file, <get "SelectedItemsPathNames" <crlf>>, <crlf>) {
        $contents = $contents . "[$file]" . <crlf> . readfile($file) . <crlf>;
    }
    writefile($targetFile, $contents);
Adapt the $targetFile variable if necessary...
One of my scripts helped you out? Please donate via Paypal

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: Request: merge files in one + make paths as title of par

Post by DmFedorov »

I get only NewTranslation.txt 0KB Ok. I must select. Good
And I need both actions: "Assemble and disassemble file"

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Request: merge files in one + make paths as title of par

Post by highend »

And you did select files in the branch view? Which ones?

MAKE SURE you NEVER have a filename that contains "[" or "]" and try this stuff on
backup data before you use it in production (because I'm not responsible for overwritten files (that's what disassembling does)!
and the whole thing will fail if any normal line from a file begins with "[". You'd need a different parsing routine to handle that more
gracefully...

Code: Select all

"_Initialize"
    setting "BackgroundFileOps", 0;
    global $targetFile = "<curpath>\NewTranslation.txt";

"Assemble file"
    global $targetFile;
    $contents = "";
    foreach($file, <get "SelectedItemsPathNames" <crlf>>, <crlf>) {
        $contents = $contents . "[$file]" . <crlf> . readfile($file) . <crlf>;
    }
    writefile($targetFile, $contents);

"Disassemble file"
    global $targetFile;

    $sections = getsectionlist(, $targetFile);
    foreach($file, $sections, <crlf>) {
        $content = getsectionlist($file, $targetFile);
        writefile($file, $content);
    }
One of my scripts helped you out? Please donate via Paypal

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: Request: merge files in one + make paths as title of par

Post by DmFedorov »

I of course recorded NewTranslation.txt file to another location.
But in this (other) place I do not get the files from NewTranslation.txt (Regardless, I highlight the file NewTranslation.txt or not)
When I click on item "Disassemble file" nothing happens. What's wrong?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Request: merge files in one + make paths as title of par

Post by highend »

What?

You moved the $targetFile after it was created?
and you want to select it so this (moved) file is processed when "Disassemble" is used?

replace global $targetFile;
in "Dissassemble" with:
$targetFile = <curitem>;
One of my scripts helped you out? Please donate via Paypal

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: Request: merge files in one + make paths as title of par

Post by DmFedorov »

Ok. everything works. Thank you very much.

the first problem was russian characters in path.
the second one I also found. The main thing is done. The rest I probably will be able to make self.

Once again thank you very much.

Post Reply