2

So requesting some help, I am currently trying to sort out a mess in my google photos. I have downloaded the archive of my google photos and have a bunch of folders with files/photos in them. I am trying to write a batch file to move the files/photos from the folder to the root of this portable drive I am using for the cleanup.

So far I have this:

@echo off
for /f "tokens=*" %%f in ('dir /a:-D /s /b') do move "%%f" .
for /f "tokens=*" %%f in ('dir /a:D /s /b') do rd "%%f"

It works the only problem I have is that potentially there could be photos with the same filename in different folders and I don't want to overwrite.

Is there any parameter I can set on the move command to block the overwrite?

Thanks

3
  • Thanks I see the confirmation message now but it's not exactly what I need, I need to file to still move and just have the filename changed like adding a number
    – ElGabbu
    May 17, 2016 at 17:01
  • Changing your question after you've received answers is inappropriate, as it invalidates the answers you've received. It can even make those answers wrong, and adversely affect the reputation of those who answered. If you now have a new or additional question, create a new post and ask it there; you can link back to this one if needed for reference.
    – DavidPostill
    May 17, 2016 at 17:06
  • @DavidPostill i have created a new question here superuser.com/questions/1077934/…
    – ElGabbu
    May 17, 2016 at 17:38

1 Answer 1

0

Is there any parameter I can set on the move command to block the overwrite?

You can use the /-Y switch (Enable confirmation prompt, when overwriting files).

The following trick will answer n, so the move doesn't happen:

echo n|move /-y "%%f" .

Notes:

  • This trick only works for a single file, no wildcards

  • If a file is not moved your following rd command will fail with th following error:

    The directory is not empty.
    

Further Reading

2
  • thanks, is there any way to still make the move but slightly change the filename ... like add a number before the extension
    – ElGabbu
    May 17, 2016 at 17:07
  • Yes. But that requires a lot more work.
    – DavidPostill
    May 17, 2016 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .