Copy Here

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Copy Here

#1 Post by drgt » 17 Oct 2021 02:31

In windows explorer, right clicking, dragging a file and dropping in the same pane, the option to copy here is given.
When taken, a new file is created "Copy (x) of ..."

How to do the almost the same in command line appending (x) to the end of the file name where x is an ascending number depending on the number of existing copies.

We can call that CopyHere.bat

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Copy Here

#2 Post by aGerman » 17 Oct 2021 03:52

There is no built-in mechanism in any of the batch commands to append or increment an appendix for existing file names. You have to write your own code to do that by counting all files that already exist with this file name. Or try in a loop which appendix already exists.
viewtopic.php?f=3&t=6204

Steffen

drgt
Posts: 158
Joined: 21 Sep 2010 02:22
Location: Greece

Copy Here

#3 Post by drgt » 17 Oct 2021 08:46

Thank you Steffen!

Post Reply