copy to current folder with a different name

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
j0nezn
Posts: 2
Joined: 23 Jan 2009 22:58

copy to current folder with a different name

Post by j0nezn »

I am try to use a script or a user defined command to copy a file to the same directory but with an appended extension. example I want to copy C:\temp\test.ini to c:\temp\test.ini.org. I tried this

Code: Select all

copyto "<curitem>.org", "<curitem>"
which copies the file to c:\temp\test.ini.org\test.ini. Where am I getting this wrong I have tried other examples but no luck.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: copy to current folder with a different name

Post by serendipity »

j0nezn wrote:I am try to use a script or a user defined command to copy a file to the same directory but with an appended extension. example I want to copy C:\temp\test.ini to c:\temp\test.ini.org. I tried this

Code: Select all

copyto "<curitem>.org", "<curitem>"
which copies the file to c:\temp\test.ini.org\test.ini. Where am I getting this wrong I have tried other examples but no luck.
Hi and Welcome to XY,
copyto will not work because the first parameter (in your case <curitem>.org) is meant for path only and therefore it creates a folder with that name.
Try this, a bit longish though:

Code: Select all

//Duplicate file with custom extension
  focus; 
  $item=<curname>; 
  #201; 
  #202; 
  setting HideFoldersInList; 
  sortby c, d; 
  sel 1; 
  rename b, "$item.org/e";
Maybe there is a shorter script, but right now I am in a hurry.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: copy to current folder with a different name

Post by TheQwerty »

You could do this with New()..

Code: Select all

::New("<curname>.org", "file", "<curitem>");
Will create a copy of the currently selected and focused file with ".org" appended to the name.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: copy to current folder with a different name

Post by serendipity »

TheQwerty wrote:You could do this with New()..

Code: Select all

::New("<curname>.org", "file", "<curitem>");
Will create a copy of the currently selected and focused file with ".org" appended to the name.
Thanks!! I was actually looking for this low level copier before posting my longish script.

j0nezn
Posts: 2
Joined: 23 Jan 2009 22:58

Re: copy to current folder with a different name

Post by j0nezn »

TheQwerty wrote:You could do this with New()..

Code: Select all

::New("<curname>.org", "file", "<curitem>");
Will create a copy of the currently selected and focused file with ".org" appended to the name.
Thanx worked like a charm would have never thought of using new.

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

Re: copy to current folder with a different name

Post by admin »

j0nezn wrote:
TheQwerty wrote:You could do this with New()..

Code: Select all

::New("<curname>.org", "file", "<curitem>");
Will create a copy of the currently selected and focused file with ".org" appended to the name.
Thanx worked like a charm would have never thought of using new.
Yes, it's surely unusual to use new for a copy. But it starts making sense when you think of the "[Shell] New" items offered in Explorer, which in fact are nothing but copies as well. And it's the same with XYplorer's "New Items" menu, where you can create "prefilled" new items.

Post Reply