Jump to content

index of file tree and labels


Recommended Posts

The following is the matter:

 

I want to implement a system that can

- take a directory tree or index file; basically, this can be seen as the master/reference

and with that

- recreate parts of that index or directory tree; basically, this can be seen as a subset of the master

- create a printfile (.ps or .pdf, or whatever) with labels of all directories/index entries, with 'chapter' names in one font (+2 pts, bold), paragraph names in another (+1 pt, italic) etc..

 

 

Now, the thing is, I don't know what is the easiest way to start on this.

 

I would like to do this that and the other using things I know (bash scripting, just some) but am not sure how far I'd get. Have done c and c++ at some point, not hot on that, but if I have to....

(Maybe this should be done with some other tool/program?)

So, could that be done, and what would be the easiest way:

-create (take) the reference directory structure as a basis, or

-create a file containing all info as a basis?

And with what tools?

 

 

 

Anyway, to explain a bit more, think of the kernel makexconfig (or whatever it is called nowadays), where you can indicate which modules you want.

 

So imagine a file/directory tree, where all desired parts can be checked/selected, and some subparts can then be deselected etcetc.

 

Then on the click of a button (or with a command), the new subset is created, either in one file (index-like) or as a directory tree. Also, with one command, a ps or pdf (or other printformat) file must be created (A4 paper format with 3cols 9rows of labels) with all entries as labels.

It would be nice if you can create this printfile of only a subset of the new subset, imagine some parts were forgotten, and have to be added; then only the labels for the new parts would have to be printed, the others should be already done.

Edited by aRTee
Link to comment
Share on other sites

Not really getting what your trying to explain but for creating and navigating files and file directories and making pdf's the best language for me is php and the www.fpdf.org pdf addon classes.

If you want a gui tool then that is harder but possible with php-gtk, or mozilla xul application with php creating the xml that the xul app reads the generate xml.

Or you can go with the web form method which i think is the most simple method.

 

If you could further explain.

Are you saying you want to have a view of a selected directory and all it's children including files. Then be able to select any child directory or files or combination and recreate the selected elements at another location possibly not within the parent directory tree?.

 

What do you mean by index file, is it a created text file with infomation on the directory and file structure?

Link to comment
Share on other sites

Hi johnnyv,

 

thanks for thinking with me on this.

 

 

Ok, to explain further: the only thing that is necessary is to duplicate a directory structure, so no files in there.

Basically, the duplicate should contain only certain parts of the reference structure (which also doesn't contain any files - it's just a template). To have that, one way would be to just copy the complete reference structure and then delete all the parts that aren't needed anymore. Or one could have a GUI like makexconfig where the user can tick the boxes for all parts that need to be included in the new version/derivative.

Next: the directory structure as derived from the template/master/reference (what should I call it?) should be converted to a printable file with labels, one per directory name, and in a font that can be chosen and which is different per depth of the directory - so that those labels can be used to tag a classifying system in a cabinet or whereever (real life, not in the computer) with the same structure as the directory structure on the computer.

 

Now, this template/reference/master structure could be an actual directory structure or could be described / contained within one (text or other) document.

 

Hope this clears things up enough - if not, let me know...

Link to comment
Share on other sites

It is trivial to grab the child directories from a specified parent, thats the easy part the pdf printing part is trivial as well. I think a web form will be the quickest way.

 

Say you have a directory structure like so:

 

                                                          A
                       B1                              B2                                        B3
              C1             C2         |           D1            |            E1           E2             E3
              F1                           |                            |                                             G1
                                             |                            |                                             H1

 

Ok so if you pick B1 and all its children but also want G1 and child you will need to include E3 and B2 to keep seperate from B1, or do you want to move G1 to be a brother to B1?

Edited by johnnyv
Link to comment
Share on other sites

Well, ideally, if I would pick only some subdirs, it should keep everything together in the same structure, so no partial trees.

Picking F1 (and including all child dirs) and H1 (and including all child dirs) would thus mean:

Through F1 also:

C1, B1 and A (all the way up)

and through H1 also:

G1, E3, B3 and A

 

So the whole structure and all levels must remain the same, including all relative positions.

 

Also, suppose that that was initially the desired subset (which must then be copied as such into maybe a zip file or so) which gets copied and placed on another system, and it is found that also C2 and E2 including their child dirs must be added, this must be easily possible.

 

See it like a real life library, where you have the various shelves ordered to subject - childrens books, scientific books, novels, etc, and each subject is classified in its particular subclasses, for childrens books for instance in age groups, for novels into language (english, french, dutch, chinese), then into authors name or so.

One library subsidiary or department may not have childrens books nor any scientific books, only english novels and some other stuff.

Then at some point they may choose to include non-english novels and scientific works.

Another department may be newly created just for kids, so they will only want the flie tree for kids books.

 

So, the 'limited' versions must not include all the subtrees that are not going to be used (especially since the labels must not be printed and the user of the system must not be bothered by tens or hundreds of non-relevant subdirectories) - in my case an expansion will not happen often, but it may.

 

Note that if only a subdir G1 with some or all of its children must be added, it is acceptible if only G1 and children get copied - the important thing is that it is relatively easy to put that into some existing structure that starts with A. In which case it may well be the simplest (also to use) if all starts at A.

Also, the target systems on which the directory structure unfolds is likely Win2k or XP - don't know how that behaves if you unzip a file with subdirs onto already existing subdirs - have to try (quite tough, no windows in my home.. and now on linux at work too..).

 

 

BTW I hadn't even though about doing things with a webform, which is definitely a good option...

Link to comment
Share on other sites

  • 2 weeks later...

I have been a little busy lately here is a function that returns an array of directories from a given path

 

<?php
function map_directories($path) 
{
$continue = true;
$final_array = array($path);
if($handle = @opendir($path))
{
     while(false !== ($file = readdir($handle)))
     {
      	 $type = filetype("$path$file");
    	 if($type == "dir" && $file != "." && $file != "..")
	 {
	 $directory_array[] = $path.$file."/";
	 }
 }
}
closedir($handle);
while($continue)
{
 if(isset($directory_array))
 {
               $final_array = array_merge($final_array,$directory_array);
 $temp_array = $directory_array;
 unset($directory_array);
	 foreach($temp_array as $path)
	 {
   if($handle = @opendir($path))
   {
      	 while(false !== ($file = readdir($handle)))
      	 {
  	 $type = filetype("$path$file");
     if($type == "dir" && $file != "." && $file != "..")
     {
     $directory_array[] = $path.$file."/";
     }
  	 }
   closedir($handle);
   }
	 }
 }
 else
 {
 $continue = false;
 }
}
return $final_array;
}
// example
$list = map_directies('/home/john/Desktop/'); // need that trailing / or add error checking
print_r($list);
?>

 

For pdf creation exaples look at www.fpdf.org

For redistribution to windows i don't really know, but if you make a zip file with the directories it should work. For that you will want to use mkdir() to make the directories in a temp folder and then zip them.

Php only supports tar, gz and bz2 natively so you would need to use an exteranal command to creat zip files, which you can do from php with the system() or exec() etc functions.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...