79669606

Date: 2025-06-17 18:30:06
Score: 0.5
Natty:
Report link

Hey! The reason your command didn’t work is due to a few issues:

  1. %nxF is invalid — it should be %~nxF to get the filename and extension.

  2. rm isn’t a valid command in Windows CMD — use del instead.

  3. Quoting %Dir2%\* like "%Dir2%\*" breaks the wildcard — CMD won't expand it properly.

  4. You're using variables like %Dir1% inside the for loop, but CMD may not expand them correctly there.

Here’s a working version for CMD (replace <username> and <folder>):

for %F in (E:\*) do @if exist "D:\Users\<username>\<folder>\%~nxF" del "E:\%~nxF"

and if you want to test first:

for %F in (E:\*) do @if exist "D:\Users\<username>\<folder>\%~nxF" echo del "E:\%~nxF"

Let me know if you're running it from a batch file — the syntax changes slightly!

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Guillermo