How to duplicate easily one file in N copies ?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
jjk
Posts: 202
Joined: 10 Oct 2007 20:11
Location: Paris

How to duplicate easily one file in N copies ?

Post by jjk »

Hi all,
I 'd like to copy the selected file (or even the selected files) in the same directory.
Say that the source is dir\Myfile.txt
I want to get dir\Myfile-01.txt, dir\Myfile-02.txt, dir\Myfile-03.txt, and so on.

While dir\Myfile.txt is selected, I hit Ctrl-D (Copy Here with number). That's OK.
dir\Myfile-01.txt is created, but dir\Myfile-01.txt is now selected.
So, if I want to get dir\Myfile-02.txt I have to first select dir\Myfile.txt before hitting Ctrl-D.
If I want duplicate dir\Myfile.txt say 100 times, it is a pain to have first to select the original file before duplicating it.

Perhaps a script could realize that ?
If not, I'd like an option to have, in case of duplicating in place, the target selected rather than the source. So I'd hit Ctrl-D 100 times and that's all.

Thanks in advance.
Last edited by jjk on 04 Nov 2010 14:29, edited 1 time in total.

zer0
Posts: 2676
Joined: 19 Jan 2009 20:11

Re: How to duplicate easily one file in N copies ?

Post by zer0 »

This ought to do it. It makes 100 copies, as per your question...

Code: Select all

$initialFile = "<curitem>";
    $count = 0;
    while ($count < 100) {
      new(, , "$initialFile");
      $count++;
    }
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: How to duplicate easily one file in N copies ?

Post by SkyFrontier »

For the sake of usability, I'd like to suggest a little interface for having an easier control over the total of files to be created.

-will ask user on the total number of files to be created, then replicating at that given value.

Code: Select all

   input $total, "This will replicate current selected item. Please enter the total of files to be created:", "99";
   $initialFile = "<curitem>";
    $count = 0;
    while ($count < $total) {
      new(, , "$initialFile");
      $count++;
    }
Thank you, zer0! This will be great for creating test dummy files with little effort.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

jjk
Posts: 202
Joined: 10 Oct 2007 20:11
Location: Paris

Re: How to duplicate easily one file in N copies ?

Post by jjk »

Thank you both.
It works very well and it is very useful and handy. 8)

Post Reply