Copying and renaming files with same name
Posted: 17 May 2019 11:24
Hello guys! I recently made a script that copies every single file from a folder - no matter if it's inside another folder in this folder - to another folder of my choice, so I can see all the files in a single place. Here it is:
For /r "c:\source" %d in (*) do copy "%d" "E:\destiny"
The problem is, there are some files with the same name, I mean: c:/source/folder1/FileName.pdf has the same name as c:/source/FileName.pdf
And I would like to, instead of substitute it or not, rename it to FileName1 - also, if there are 3 files, make it rename the third one to FileName2 and so on
Is it easy to do that? I'm new to scripts and I feel like I need to use a "for". Can someone give me a hand?
Sorry for bad english! =)
For /r "c:\source" %d in (*) do copy "%d" "E:\destiny"
The problem is, there are some files with the same name, I mean: c:/source/folder1/FileName.pdf has the same name as c:/source/FileName.pdf
And I would like to, instead of substitute it or not, rename it to FileName1 - also, if there are 3 files, make it rename the third one to FileName2 and so on
Is it easy to do that? I'm new to scripts and I feel like I need to use a "for". Can someone give me a hand?
Sorry for bad english! =)