Folder Copy w/sub levels.

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Folder Copy w/sub levels.

Post by Stefan »

1. wish:
admin wrote: copy the folder to the clipboard (select folder, then Ctrl+C),
then goto the target
and do menu Edit / Paste Special / Paste Folder Structure.
Note: usually i am on an file for which i want to make the same folder structue in an other folder.
So i want to ask to let this feature works for <curitem(s)> too, taking just the parent folder as argument.


2. wish:

Code: Select all

new()
Creates a new file or folder.

Syntax 
      new(name, [type=file|dir], [source], [rename=|r])

        name [Required] Name of the new item to be created.
        If no path is passed, the current path is taken as default. 
As far as i see,
If no full path is passed
Then only the last folder from an path string is created:

Code: Select all

new "sub folder\fld", dir;   //only "fld" is created here.
i have to use

Code: Select all

new "<curpath>\sub folder\fld", dir;  
to create all new sub folders


So i think from my point of view this could be improved.
And as second improvement i suggest to auto remove the colon if any.

Right now i use:

Code: Select all

$path= "<curpath>";
 $path= replace($path, ":");
 $item= "<curname>";
 focus "PI";
 new "<curpath>\$path", dir;
 //copy file code goes here

GamaRex
Posts: 51
Joined: 13 Jan 2010 22:04

Re: Folder Copy w/sub levels.

Post by GamaRex »

Success! I installed v9.90.0500 and experimented with the codes provided.

For the record, here are the scripts that worked:

$colFullPath = folderreport("dirs", "r", , "r");
$colRelativePath = replace($colFullPath, "<curpath>\");
msg $colRelativePath;
copytext $colRelativePath; //to clipboard

Address bar:
::folderreport("dirs", "clipboard", ,"r");

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Folder Copy w/sub levels.

Post by j_c_hallgren »

GamaRex wrote:Success! I installed v9.90.0500 and experimented with the codes provided.
Good ! Figured that you had vers that was too old...
For the record, here are the scripts that worked:

Code: Select all

$colFullPath = folderreport("dirs", "r", , "r");
   $colRelativePath = replace($colFullPath, "<curpath>\");
        msg $colRelativePath;
        copytext $colRelativePath; //to clipboard

Address bar:
::folderreport("dirs", "clipboard", ,"r");
FYI: It helps readability to select your script code and use the forum 'code' tags.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

GamaRex
Posts: 51
Joined: 13 Jan 2010 22:04

Re: Folder Copy w/sub levels.

Post by GamaRex »

FYI: It helps readability to select your script code and use the forum 'code' tags.
I can see the difference. I'll try that when I have code to post in the future. Thanks!

admin
Site Admin
Posts: 64880
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Folder Copy w/sub levels.

Post by admin »

Stefan wrote:1. wish: ...
All wishes agreed and fulfilled.

Exception: auto remove the colon -- I'm not sure if this is good. It could hide a mistake from the user.

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Folder Copy w/sub levels.

Post by Stefan »

admin wrote:
Stefan wrote:1. wish: ...
All wishes agreed and fulfilled.
Thank you.
Stefan wrote:2. wish: i suggest to auto remove the colon if any.
Exception: auto remove the colon -- I'm not sure if this is good. It could hide a mistake from the user.
Yes you are right.

For example creating an collection using folderreport("dirs", "r", , "r");
and use this as template for new folders.

Right now it would create an absolute path if the drive exist:
new "C:\temp\sub folder\fld", dir;

My suggestion would create an relative path as sub-folders:
new "C\temp\sub folder\fld", dir;

But I think we can handle this our own by using
$path= replace($path, ":");
right before using new()


But for an non-script solution there could be an option to remove the colon
so the average user can duplicate an folder structure.


I see there is
EDIT > Paste Special > Paste Folder structure
and
d&d context menu > create folder/branch here
but they both only create sub-folders, starting from current folder.
( While i am in "X:\one\two\three" i get only "three\four\five\" )

But often i need to make an copy of the parent folders structure.
( While i am in "X:\one\two\three" i need to get "X\one\two\" as copy [included an GoTo deepest sub-folder?].
And then i would copy "three\four\five\" into that new created path )


(sorry. it's more then i want to suggest right now. but as i am on it...)
.

admin
Site Admin
Posts: 64880
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Folder Copy w/sub levels.

Post by admin »

Well, try to find some fellows for this wish... I think it's a bit exotic. Such refinements should be left for scripting.

Post Reply