Page 1 of 1

paste folder structure with thumbnails

Posted: 04 Apr 2015 20:47
by Stef123
[split from http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=13740 ]
SammaySarkar wrote:isn't the current path is selected in the folder picker
Not for my mapped drive. But you're right, I just ran it on my local D-Drive and it works.
SammaySarkar wrote:Copy a folder then Edit > Paste Special > Paste folder structure. :ugeek:
:oops: Yes, in fact, this reminds me of something I've been wanting to try for a long time, so this is off topic - how I do paste the folder structure WITH the corresponding folder thumbnails? What I had in mind was pasting the folder structure, then doing a rich copy restricted to folder.jpgs only - would you share your thoughts :idea: on this? Give me some syntax pointers? My ultimate goal is to automate this via SC (folder thumbs structure view) :?:

Re: ShadowCats [beta]

Posted: 07 Apr 2015 06:13
by bdeshi
here's a not-very-elegant scriptlet:

Code: Select all

//copy some items, go to paste target, and run this script instead of pasting folder structure
  end (strpos(get('clipboardformats'),'cf_hdrop') == -1) ; //end if clipboard doesn't have file/folders
  $target = <curpath>;
  //$target = (exists(<curitem>) != 2) ? <curpath> : <curitem> ; //match Configuration > Controls and More > Miscellaneous > Paste to selected list folder
  foreach ($item, <clipboard>, <crlf>){
    if (exists($item) != 2) { continue; } // move on if not folder
    $itembase = getpathcomponent($item, 'file'); //basepath of $item
    $lst = trim(folderreport('dirsrel', 'r', $item, 'r'),<crlf>,'R'); //recursive subdir list
    foreach ($itm, $lst, <crlf>) {
      if   (exists("$item\$itm\folder.jpg") == 1) {
        new("$target\$itembase\$itm",'dir');
        copyitem "$item\$itm\folder.jpg" , "$target\$itembase\$itm\folder.jpg"; }
      else  {
        new("$target\$itembase\$itm",'dir'); }
    }
  }
although this can already be shortened by a few lines, I was sure XY would have some much easier ways to do something like this.

Re: ShadowCats [beta]

Posted: 07 Apr 2015 22:57
by Stef123
And once again - thank you for helping me out. :biggrin:
Could you make it work for folder.png as well? When I "expanded" it with an OR addition, I broke it. :whistle:
SammaySarkar wrote:I was sure XY would have some much easier ways to do something like this.
I am glad YOU say this. It's exactly the reason I never tried to tackle it myself, always thinking I'll come across a feature/ switch/ command which does it all by itself, similar to "paste folder structure", much smarter than anything I'd ever come up with.

Anyway, your script handles it nicely, except for one little thing: It won't copy the folder.jpg of the first level, if this level contains subfolders. However, for the deeper levels it digs them out.
I copy Folder1 and Folder2. Upon pasting...

Code: Select all

Folder1 = OK (it has no subfolders)
Folder2 = no thumb
Folder2.1 = OK
Folder2.2 = OK
If however, I start one level higher, by copying Folder0, I get the missing thumb for Folder2 (but now Folder0 is missing his folder.jpg)

Code: Select all

Folder0 = no thumb
Folder1 = OK
Folder2 = OK
Folder2.1 = OK
Folder2.2 = OK

Re: ShadowCats [beta]

Posted: 08 Apr 2015 08:00
by bdeshi
"except for one little thing: It won't copy the folder.jpg of the first level, if this level contains subfolders." -- that's how lazy scripters and their scripts work :oops:
Try this iteration.

Code: Select all

// step;
//copy some items, go to paste target, and run this script instead of pasting folder structure
  end (strpos(get('clipboardformats'),'cf_hdrop') == -1) ; //end if clipboard doesn't have file/folders
  $target = <curpath>;
  //$target = (exists(<curitem>) != 2) ? <curpath> : <curitem> ; //match Configuration > Controls and More > Miscellaneous > Paste to selected list folder
  foreach ($item, <clipboard>, <crlf>){
    $itembase = getpathcomponent($item, 'file'); //basepath of $item
    if (exists($item) != 2) { continue; } // move on if not folder
    if (exists("$item\folder.jpg") == 1) || (exists("$item\folder.png") == 1) {
      if (exists("$target\$itembase") == 0) { new("$target\$itembase",'dir'); }
      copyitem "$item\folder.jpg" , "$target\$itembase\folder.jpg"; 
      copyitem "$item\folder.png" , "$target\$itembase\folder.png";
    }
    $lst = folderreport('dirsrel', 'r', $item, 'r'); //recursive subdir list
    foreach ($itm, $lst, <crlf>) {
      if ($itm == '') { continue; }
      if (exists("$item\$itm\folder.jpg") == 1) || (exists("$item\$itm\folder.png") == 1) {
        if (exists("$target\$itembase\$itm") == 0) { new("$target\$itembase\$itm",'dir'); }
        copyitem "$item\$itm\folder.jpg" , "$target\$itembase\$itm\folder.jpg"; 
        copyitem "$item\$itm\folder.png" , "$target\$itembase\$itm\folder.png";
      }
      else  {
        if (exists("$target\$itembase\$itm") == 0) { new("$target\$itembase\$itm",'dir'); }
      }
    }
  }

Re: paste folder structure with thumbnails

Posted: 08 Apr 2015 08:52
by Stef123
It's perfect now. :tup: :ball: Seriously. I wish I'd had this a few weeks ago, when I was going nuts during phone support for a client. Went over my notes, desperately trying to come to terms with his folder structure.

You have no idea what a time saver this is, for someone who takes screenshots of folder views, invents naming schemes to represent folder hierarchy levels ....
Your script allows me to take my folder.jpgs home with me, they're no longer confined to drives and machines and offices. Many MANY T-H-A-N-K-S :beer: :beer: :beer:

Re: paste folder structure with thumbnails

Posted: 08 Apr 2015 14:35
by bdeshi
Image

[Glad to help!]

Re: paste folder structure with thumbnails

Posted: 08 Apr 2015 14:39
by Stef123
Hehe :titter: - emoticons as customized as your solutions