paste folder structure with thumbnails

Discuss and share scripts and script files...
Post Reply
Stef123

paste folder structure with thumbnails

Post 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) :?:

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: ShadowCats [beta]

Post 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.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Stef123

Re: ShadowCats [beta]

Post 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

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: ShadowCats [beta]

Post 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'); }
      }
    }
  }
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Stef123

Re: paste folder structure with thumbnails

Post 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:

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: paste folder structure with thumbnails

Post by bdeshi »

Image

[Glad to help!]
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Stef123

Re: paste folder structure with thumbnails

Post by Stef123 »

Hehe :titter: - emoticons as customized as your solutions

Post Reply