-2
@echo off
set "destination=%%~dpI"
for /r %%f in (*.*) do (
  copy %%f +*
)

I have this batch script, and it works perfectly fine as long as the current directory has no spaces. If there are spaces, this doesn't work. How can I fix this?

G27nS4gD
  • 1
  • 2
  • `copy "%%f" +*` – Stephan May 30 '22 at 13:58
  • Actually, this just copies all the files in a directory/it's subdirectories to the main directory, but I'm wanting to copy the files over themselves. Do you know how I could do this? – G27nS4gD May 30 '22 at 14:07
  • Basically, I have a main directory with files and subdirectories, and I'm wanting to make copies of everything inside the main directory on themselves, so every file/folder inside the main directory updates the timestamp. – G27nS4gD May 30 '22 at 14:08
  • So you actually don't want to copy files, but update their timestamps? (Then why the wildcard?) What about `it works perfectly fine ...`? Please edit your question to clarify. – Stephan May 30 '22 at 14:16
  • I want to copy the files which in result gives them new timestamps, and I thought it was working when I tested it on a directory with no subdirectories. – G27nS4gD May 30 '22 at 14:18
  • put `%%f` in quotes to cure the issue with spaces and get rid of the `*` – Stephan May 30 '22 at 14:23
  • This just copies everything to the current directory, how can I copy these files over themselves? – G27nS4gD May 30 '22 at 14:25

0 Answers0