Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: batch del files in subfolders only certain file exist

 05 Sep 2017 #1 goodywp Ontario 3 posts batch del files in subfolders only certain file exist Hi all, I just want a batch file to delete all files with extension *.P3? in all subfolders on condition only some file exist in these subfolders like *.pkg file C:\test\abc\*.P3A, *.pkg C:\test\def\*.P3L C:\test\ghi\*.P3P, *.pkg So the script should only delete *.P3A in abc folder and also *.P3P in ghi folder Thanks My System Specs
 .
 05 Sep 2017 #2 samuria win 8 32 bit 1,914 posts crewe uk Welcome to the forum. if I understand you you want Code: cd\test del *.p3* /s My System Specs
 05 Sep 2017 #3 SmithJohn Windows 8 32 bit 2 posts Batch for Delete all Occurences in SubFolders I think you need the following : Code: ECHO OFF CLS del /s "c:\directory\*.pkg" @ pause Best regards My System Specs
 .
 06 Sep 2017 #4 goodywp Ontario 3 posts how to delete certain files only some file exist in subfolder in batch Thanks to both of your replies. What I really want is a batch file to do: 1) if the *.pkg file exist in subfolder 2) then delete *.P3? files, it could be *.P3A, *.P3P, or *.P3L C:\test\abc\*.P3A, *.pkg C:\test\def\*.P3L C:\test\ghi\*.P3P, *.pkg So the batch script should only delete *.P3A in abc folder and also *.P3P in ghi folder Thanks My System Specs
 06 Sep 2017 #5 samuria win 8 32 bit 1,914 posts crewe uk Post two should do that My System Specs
 06 Sep 2017 #6 SmithJohn Windows 8 32 bit 2 posts Try this    Quote: Originally Posted by goodywp Thanks to both of your replies. What I really want is a batch file to do: 1) if the *.pkg file exist in subfolder 2) then delete *.P3? files, it could be *.P3A, *.P3P, or *.P3L C:\test\abc\*.P3A, *.pkg C:\test\def\*.P3L C:\test\ghi\*.P3P, *.pkg So the batch script should only delete *.P3A in abc folder and also *.P3P in ghi folder Thanks I'm sorry, I was on the moon Ok, you can adapt the following code to what you need, I hope it's what you're looking for. Code: ECHO OFF CLS if exist c:\directory1\*.pkg goto deleting1 if exist c:\directory2\*.pkg goto deleting2 :deleting1 del "c:\directory1\*.pkg" del "c:\directory1\*.P3A" del "c:\directory1\*.P3L" del "c:\directory1\*.P3P" :deleting2 del "c:\directory2\*.P3A" del "c:\directory2\*.P3L" del "c:\directory2\*.P3P" @ pause My System Specs
 06 Sep 2017 #7 goodywp Ontario 3 posts Hi Samuria, there is also the below folder which has *.P3L file and could be deleted as well. The intended is not deleting the file in the folder since it doe not have*.pkg file in this folder C:\test\def\*.P3L Thanks My System Specs
 06 Sep 2017 #8 samuria win 8 32 bit 1,914 posts crewe uk It should delete any file that has .P3 and anything else the /s tells it to do the same in sub directory My System Specs

batch del files in subfolders only certain file exist

 Thread Tools

 Similar help and support threads Thread Forum Auto-Apply prompt rule to ALL files when target file already exist?I sometimes copy/move multiple files + folders within WinExplorer by Drag&Drop to another folder where these files & folder already exist (as an older version with the same name). Then always a popup prompt appears aksing me if I want to - replace the old existing files - cancel the... Installation & Setup Window Batch file to delete folders/subfolders that contain filesI have a root folder called "Names"..It has subfolders ,these subfolders contains files. I will be giving the names of subfolders to be deleted in text file Ex.. John Tom Rambo. I will be reading the folder names from text file & delete only those folders with files inside the folder also .... General Discussion Win7 file search returns no files (but they exist)Greetings - Running Win7 (6.1, SP1, 64-bit). Previously, I was using WinXP file search in classic mode. Predictable, reliable results. I'm finding Win7 file searching to be unpredictable at best. I have dozens files of the form xName-, where x is my first initial, Name is my... Performance & Maintenance How to create a batch file that will move files based on the file typeHow to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent... General Discussion My Docs subfolders exist, but don't display in ExplorerI am running a dual boot with 7 and XP, 32-bit. I used Windows Easy Transfer to transfer all of my files over to the 7 partition. I have about 10 subfolders in "C:\Users\*USER*\Documents\" When I view the folder in Explorer, however, no folders are displayed. I can access them if I directly... General Discussion

 Our Sites Site Links About Us Find Us Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp. © Designer Media Ltd All times are GMT -5. The time now is 01:10.