Copy files to file collection recreating the same folder structure

Hi guys,
I would like to know if it's possible to move selected files to the file collection with the parent folders of the selected files. Let's say I copy image1 and image2 to the file collection from a folder named Photos and its parent folder is "Adam Levine", but in file collection there should be the folder "Adam Levine " and it's subfolder Photos that contains the two mentioned images above
There is something similar here

But I need it in file collection.

This seems to work:

@nodeselect 
@set mnc=coll://MyNewCollection
CreateFolder NAME={$mnc}
CreateFolder NAME={$mnc}\{sourcepath|..|nopath}
CreateFolder NAME={$mnc}\{sourcepath|..|nopath}{sourcepath|nopath|noterm}
Copy COPYTOCOLL=sub TO={$mnc}\{sourcepath|..|nopath}{sourcepath|nopath|noterm}

A linked account is good forum etiquette.

Thanks a lot Ixp, works perfect. But how to move the files to the already existing file collection "Duplicate Files" It creates a new file collection folder

I didn't actually know that. Will do that

Try

@nodeselect
@nofilenamequoting
@set mnc=coll://Duplicate Files
CreateFolder NAME="{$mnc}"
CreateFolder NAME="{$mnc}\{sourcepath|..|nopath}"
CreateFolder NAME="{$mnc}\{sourcepath|..|nopath}{sourcepath|nopath|noterm}"
Copy COPYTOCOLL=sub TO="{$mnc}\{sourcepath|..|nopath}{sourcepath|nopath|noterm}"
1 Like

Thank you so much. It's amazing! Just one last question. Can I integrate this button with this script-addin below, so when I randomly select n items it used these commands you haved suggested above

Haven't tried, but starting the button with the SelectRandom command should work.

1 Like

Thanks

Couldn't link the account with my 60 days free version

If I past it after SelectRandom it moves files to the collection but not the ones that have been selected. I tried to past your code after COMMAND. But it doesn't create the structured folders.

Set VIEW=Thumbnails
SelectRandom NAME=".*(\.jpg|png)" COPYTOCOLL="Duplicate Files" FILES ITEMCOUNT=1 COMMANDS=ScrollSelectionIntoView\n@nodeselect\n@nofilenamequoting\n@set mnc=coll://Structured Collection\nCreateFolder NAME="{$mnc}"\nCreateFolder NAME="{$mnc}\{sourcepath|..|nopath}"\nCreateFolder NAME="{$mnc}\{sourcepath|..|nopath}{sourcepath|nopath|noterm}"\nCopy COPYTOCOLL=sub TO="{$mnc}\{sourcepath|..|nopath}{sourcepath|nopath|noterm}"

Ah yes, of course... :frowning:

No, sorry, you have to use two separate buttons or modify the SelectRandom jscript to also execute the commands from above.

Yes, I was actually thinking about it. Do you know how to trigger a button click(maybe with its hotkey) in the script itself?

That would have been a much better solution. I did some horrible things in the script but soon realised that I have always been bad at coding :grinning:

Actually, there is a one-button solution.... :slight_smile:

Turn the commands into a user command and execute it after the SelectRandom command:

1 Like

Thank you so much for your time and help. Everything is fine now. :+1: