Copy folder with parent

Hi guys,

I'm sure this is simple but I can't work it out. I need a command to copy the selected folder(s) and parent folder from the source to the destination. Simple as it... or is it.

For example, I have the folder Relics selected in the S:\Music\Pink Floyd folder, run the command and it will copy the selected folder, maintaining the folder structure. (i.e. D:\Pink Floyd\Relics)

Regards

Blueroly

[code]@nofilenamequoting

@set from={filepath$|noterm}
@set to={destpath|noterm}{filepath$|..|noroot|noterm}

Say FROM0: {$from}
Say FROM1: {filepath$|noterm}
Say TO0 : {$to}
Say TO1 : {destpath|noterm}{filepath$|..|noroot|noterm}

Say CreateFolder NAME="{$to}"
Say Copy FILE="{$from}" TO="{$to}"

CreateFolder NAME="{$to}"
Copy FILE="{$from}" TO="{$to}"
[/code]
Seems to do what you want? o)
Remove the "Say" lines, I used them for debugging (or leave them and install this: Command: Say (print text to the script console)) Very handy for toying around with paths and commands and also may avoid some screw ups.

@devs
Because I had weird results and then decided to "echo" what the final commandsline(s) would look like, I noticed that "{destpath|noterm}" can only be used once (it seems). Is that possible? When used a second time, this expression is empty.

The button script above shows following output, note that "TO1" is not equal to "TO0":
Command.Generic: Say: FROM0: C:\ProgramData\GPSoftware\Directory Opus\Script Addins\Command.Generic_SelectEx.js
Command.Generic: Say: FROM1: C:\ProgramData\GPSoftware\Directory Opus\Script Addins\Command.Generic_SelectEx.js
Command.Generic: Say: TO0 : D:\tmp\2015_03_16 02-02-17\ProgramData\GPSoftware\Directory Opus\Script Addins
Command.Generic: Say: TO1 : \ProgramData\GPSoftware\Directory Opus\Script Addins
Btw, this is where the oldschool button mechanics really rock!
I miss these powerful string and path manipulations in "OnClick()". o)

Oops, the first attempt posted, included the path from the source root-folder on, which was not exactly what you were looking for. It also just run for the first selected item.

This should be what you were looking for, it copies selected items including their parent folder to dest:

@nofilenamequoting 
CreateFolder NAME="{destpath$|noterm}\{filepath|..|nopath|noterm}"
Copy FILE="{filepath$|noterm}" TO="{destpath$|noterm}\{filepath|..|nopath|noterm}"

This is basically the same as posted before and copies the full path:

@nofilenamequoting 
CreateFolder NAME="{destpath|noterm}\{filepath$|..|noroot|noterm}"
Copy FILE="{filepath$|noterm}" TO="{destpath|noterm}\{filepath$|..|noroot|noterm}"

@devs
It seems a script command in between "eats" {destpath}!

[quote="tbone"]This should be what you were looking for, it copies selected items including their parent folder to dest:

@nofilenamequoting CreateFolder NAME="{destpath$|noterm}\{filepath|..|nopath|noterm}" Copy FILE="{filepath$|noterm}" TO="{destpath$|noterm}\{filepath|..|nopath|noterm}" [/quote]
As ever, this is perfect tbone... it does precisely what I need. Thanks for your help.

This is all you need, unless you care about flat view or collections where files may be in different parent folders:

Copy CREATEFOLDER {sourcepath|nopath|noterm}

You'll get a better progress dialog with that, since it only runs one copy command for all the files, instead of one per file.

[quote="leo"]This is all you need, unless you care about flat view or collections where files may be in different parent folders:

Copy CREATEFOLDER {sourcepath|nopath|noterm}

Works perfectly, thanks Leo.