문제

I am trying to get a batch file that will look in C:\users\public\desktop and then delete any duplicate shortcut links like Shortcut (1) but leave the original.

Can something like this work? where you look at what files are in the directory and if it matches the file and has (1) or (2) at the end delete it. Example:

  • myfilelink.lnk
  • myfilelink (1).lnk
  • myfile2.lnk
  • myfile2 (1).lnk

then delete the ones with (1) at the end?

This is what I have so far but im not sure how to look at %%a and see if it has a (1) in the string. Then if it does Delete it.

@echo off
for /R "C:\Users\user\Desktop\Testing" %%a in (*.lnk) do IF %%a
PAUSE
도움이 되었습니까?

해결책

Add /s if you want it to act recursively.

del "C:\users\public\desktop\*(1).lnk"
del "C:\users\public\desktop\*(2).lnk"

or this if you are sure of the match:

del "C:\users\public\desktop\*(?).lnk"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top