What I want to do is have a batch file search folders, and subfolders, for matching file names that are ending in .mp3 and .wma and delete or move the *.wma duplicates.
Below you'll find what I have come up with until now, I know it is wrong for at least two reasons. I have searched the internet, and tried a number of things, but now I am stuck. Can anyone please help me with this?
for /r %%f in "(%userprofile%\my music\* - ?.*)" do del "%%f" /s/p 2 4 Answers
I'm no windows guru but forfiles is pretty straight forward.forfiles /p "%userprofile%\my music\" /s /m *.mp3 /C "cmd /c del @"
May I recommend powershell?
cd C:\users\Administrator\Desktop\test\
$Afiles = ls *.text
$Bfiles = ls *.txt
$Alist = @()
$Blist = @()
foreach( $A in $Afiles)
{ $Alist += $A.BaseName
}
foreach( $B in $Bfiles)
{ $Blist += $B.BaseName
}
foreach($A in $Alist)
{ if($Blist -contains $a) { rm ("$A.text") -WhatIf }
}while this may seem a bit more complicated, its much more extensible and reusable IMHO.
Sorry for brining up that old question, but for anyone who stumbles here in the future, check this out, this works in a batch file:
@ECHO OFF
FOR %%A IN (A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) DO (DIR /B /S /A-D %%A:\>>FILELIST.TXT) 2>NUL this worked really great for what i needed
forfiles /P C:\Projects\QualityPush\ /S /M first.txt /C "cmd /c echo @path" forfiles /P C:\Projects\QualityPush\ /S /M second.txt /C "cmd /c echo @path"
This will give you the path to each file for any matches in sub dirs and keeps them collated together