alternative solution to use del command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
RV16
Posts: 1
Joined: 16 Mar 2016 10:22

alternative solution to use del command

#1 Post by RV16 » 03 Nov 2016 14:46

Hello,

Do we have any alternative ways to delete images without using delete command?
I am trying to copy images from one folder to another.
I just want to copy images which starts with lastname,firstname-idnum.
I want to remove images which starts with hyphen (-)
I want to remove images which starts with numbers
I don't want to use del command on my production environment, so I am looking for safe and better solution.
Would you please give me appropriate solution for that asap?

I am also sharing my code with you but for some reason it is not working properly.
@echo off

robocopy c:\images c:\images2 /XN /XC /XO
cd c:\images2
del /r \ -*.JPG

cd c:\images2
del /r \ [0]*.JPG

cd c:\images2
del /r \ [0]*.JPG

cd c:\images2
del /r \ [1]*.JPG

cd c:\images2
del /r \ [2]*.JPG

cd c:\images2
del /r \ [3]*.JPG

cd c:\images2
del /r \ [4]*.JPG


Thanks :)

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: alternative solution to use del command

#2 Post by dbenham » 03 Nov 2016 15:42

Huh :?

You say you don't want to use the DEL command, but your code uses the DEL command. :shock:

Your code cannot work because the /R switch is not valid for the DEL command. But I have no idea what you expected /R to do, so I can't suggest a fix.

What don't you like about DEL :?: What do you mean by "safe and better solution" :?:

No one can help you until you describe the DEL behavior you are trying to avoid, and what exact behavior you want.


Dave Benham

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: alternative solution to use del command

#3 Post by Compo » 03 Nov 2016 16:13

If you were to use the /XF option with RoboCopy, and potentially couple it with /L, you could effectively be sure you're not copying files over in the first instance. There would then be no need to Delete the copied files you didn't need to copy.

Post Reply