Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
goodywp
- Posts: 265
- Joined: 31 Jul 2017 09:57
#1
Post
by goodywp » 09 Jun 2022 13:05
Hi ALl,
I have a below code to copy all subfolders files to one newly made subfolder.
folder/
/Sub1
/sub2
/sub3
.......
/subfolder
Code: Select all
for /r "folder" %%d in (*) do copy "%%d" "folder\subfolder"
It works fine except in the middle having these lines
The file cannot be copied onto itself.
0 file(s) copied.
How can I get rid of these lines?
Thanks
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#2
Post
by ShadowThief » 09 Jun 2022 16:06
Stick a 2>nul at the end of the line to hide the errors
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#3
Post
by penpen » 15 Jun 2022 02:14
You should copy your files to a temporary folder (preferably on the same volume) and then move them to the final location.
penpen
-
goodywp
- Posts: 265
- Joined: 31 Jul 2017 09:57
#4
Post
by goodywp » 22 Aug 2022 11:40
Thanks I will take Stick a 2>nul at the end of the line to hide the errors