Electronics-Related.com
Forums

Windows batch file help

Started by John Larkin December 25, 2022

Given a folder C:\Protos, I want a batch file to find all sub-folders,
possibly a few levels deep, called OLD, and delete all of them. I
can't make that work.

When we develop a prototype PCB, we name iterations  board1, board2,
etc, and drag the old ones into an OLD folder until it's done. Spice
folders get a OLD sub-folder too. 

Windows batch files don't make a lot of sense to me. Too many
ambiguities.

For example, 

C:\Protos\Z540_P940_Load_Board\PCB\OLD

is full of obsolete iterations.


On Sun, 25 Dec 2022 08:04:08 -0800, John Larkin
<jlarkin@highlandSNIPMEtechnology.com> wrote:

> > >Given a folder C:\Protos, I want a batch file to find all sub-folders, >possibly a few levels deep, called OLD, and delete all of them. I >can't make that work. > >When we develop a prototype PCB, we name iterations board1, board2, >etc, and drag the old ones into an OLD folder until it's done. Spice >folders get a OLD sub-folder too. > >Windows batch files don't make a lot of sense to me. Too many >ambiguities. > >For example, > >C:\Protos\Z540_P940_Load_Board\PCB\OLD > >is full of obsolete iterations.
I'm afraid to delete old versions, because sometimes I need to go back and recover some lost item, or recover from a edit fumble. So I collect all such in a process archive of some kind, and keep it forever. Joe Gwinn
John Larkin <jlarkin@highlandSNIPMEtechnology.com> Wrote in message:r
> Given a folder C:\Protos, I want a batch file to find all sub-folders,possibly a few levels deep, called OLD, and delete all of them. Ican't make that work.When we develop a prototype PCB, we name iterations board1, board2,etc, and drag the old ones into an OLD folder until it's done. Spicefolders get a OLD sub-folder too. Windows batch files don't make a lot of sense to me. Too manyambiguities.For example, C:\Protos\Z540_P940_Load_Board\PCB\OLDis full of obsolete iterations.
It gets clunky, but not impossible. You could do a 'find' and redirect that output to a text file, the call another bat file to use the find results to delete. Powershell may have something smoother. Cheers -- ----Android NewsGroup Reader---- https://piaohong.s3-us-west-2.amazonaws.com/usenet/index.html
On Sunday, December 25, 2022 at 4:04:20 PM UTC, John Larkin wrote:
> Given a folder C:\Protos, I want a batch file to find all sub-folders, > possibly a few levels deep, called OLD, and delete all of them. I > can't make that work. > > When we develop a prototype PCB, we name iterations board1, board2, > etc, and drag the old ones into an OLD folder until it's done. Spice > folders get a OLD sub-folder too. > > Windows batch files don't make a lot of sense to me. Too many > ambiguities. > > For example, > > C:\Protos\Z540_P940_Load_Board\PCB\OLD > > is full of obsolete iterations.
Download XYplorer, it can find and list named files or directories starting from any location. It is one of the alternative to the standard windows file manager, and I would think most of the others also have this capability.
s&oslash;ndag den 25. december 2022 kl. 17.04.20 UTC+1 skrev John Larkin:
> Given a folder C:\Protos, I want a batch file to find all sub-folders, > possibly a few levels deep, called OLD, and delete all of them. I > can't make that work. > > When we develop a prototype PCB, we name iterations board1, board2, > etc, and drag the old ones into an OLD folder until it's done. Spice > folders get a OLD sub-folder too. > > Windows batch files don't make a lot of sense to me. Too many > ambiguities. > > For example, > > C:\Protos\Z540_P940_Load_Board\PCB\OLD > > is full of obsolete iterations.
https://code.adonline.id.au/powershell-delete-folders-based-on-name/ ?
On Sun, 25 Dec 2022 11:35:12 -0800 (PST), Lasse Langwadt Christensen
<langwadt@fonz.dk> wrote:

>s&#4294967295;ndag den 25. december 2022 kl. 17.04.20 UTC+1 skrev John Larkin: >> Given a folder C:\Protos, I want a batch file to find all sub-folders, >> possibly a few levels deep, called OLD, and delete all of them. I >> can't make that work. >> >> When we develop a prototype PCB, we name iterations board1, board2, >> etc, and drag the old ones into an OLD folder until it's done. Spice >> folders get a OLD sub-folder too. >> >> Windows batch files don't make a lot of sense to me. Too many >> ambiguities. >> >> For example, >> >> C:\Protos\Z540_P940_Load_Board\PCB\OLD >> >> is full of obsolete iterations. > >https://code.adonline.id.au/powershell-delete-folders-based-on-name/ > >?
Yikes. Maybe I'll just have someone do it. I could write a PowerBasic program, I guess.
John Larkin <jlarkin@highlandsnipmetechnology.com> wrote:
> > > Given a folder C:\Protos, I want a batch file to find all sub-folders, > possibly a few levels deep, called OLD, and delete all of them. I > can't make that work. > > When we develop a prototype PCB, we name iterations board1, board2, > etc, and drag the old ones into an OLD folder until it's done. Spice > folders get a OLD sub-folder too. > > Windows batch files don't make a lot of sense to me. Too many > ambiguities. > > For example, > > C:\Protos\Z540_P940_Load_Board\PCB\OLD > > is full of obsolete iterations.
start with this to get the list of dirs to delete cd c:\Protos dir /AD OLD /s /B you may need a lowercase b, you never mentioned what version of windows you're running.
On Sunday, December 25, 2022 at 6:16:13 PM UTC-5, Cydrome Leader wrote:
> John Larkin <jla...@highlandsnipmetechnology.com> wrote: > > > > > > Given a folder C:\Protos, I want a batch file to find all sub-folders, > > possibly a few levels deep, called OLD, and delete all of them. I > > can't make that work. > > > > When we develop a prototype PCB, we name iterations board1, board2, > > etc, and drag the old ones into an OLD folder until it's done. Spice > > folders get a OLD sub-folder too. > > > > Windows batch files don't make a lot of sense to me. Too many > > ambiguities. > > > > For example, > > > > C:\Protos\Z540_P940_Load_Board\PCB\OLD > > > > is full of obsolete iterations. > start with this to get the list of dirs to delete > > cd c:\Protos > > dir /AD OLD /s /B > > you may need a lowercase b, you never mentioned what version of windows you're running.
Probably 3.0. He wants to upgrade to 3.1 to use USB, but can't find a Floppy drive that's not USB. lol -- Rick C. - Get 1,000 miles of free Supercharging - Tesla referral code - https://ts.la/richard11209
On 25/12/2022 23:16, Cydrome Leader wrote:
> John Larkin <jlarkin@highlandsnipmetechnology.com> wrote: >> >> >> Given a folder C:\Protos, I want a batch file to find all sub-folders, >> possibly a few levels deep, called OLD, and delete all of them. I >> can't make that work. >> >> When we develop a prototype PCB, we name iterations board1, board2, >> etc, and drag the old ones into an OLD folder until it's done. Spice >> folders get a OLD sub-folder too. >> >> Windows batch files don't make a lot of sense to me. Too many >> ambiguities. >> >> For example, >> >> C:\Protos\Z540_P940_Load_Board\PCB\OLD >> >> is full of obsolete iterations. > > start with this to get the list of dirs to delete > > cd c:\Protos > > dir /AD OLD /s /B > > you may need a lowercase b, you never mentioned what version of windows you're running.
ITYM dir /ad .\old /s /b >badbatch.txt Otherwise it will falsely match things like bold cold fold folder told I think my search pattern is safe buit may still catch things you don't want to be zapped so double check its output! Then edlin badbatch.txt r/C:/del C:/ w q I'd check it out manually first - my edlin is a little rusty. (and I bet edlin won't run on modern Windoze PCs) It is basically just to tack "del " on the front of each line. -- Regards, Martin Brown
John Larkin <jlarkin@highlandSNIPMEtechnology.com> wrote in
news:ifsgqhp406799vf7lse21fi8ep2ubgvh9b@4ax.com: 

> > > Given a folder C:\Protos, I want a batch file to find all > sub-folders, possibly a few levels deep, called OLD, and delete > all of them. I can't make that work. > > When we develop a prototype PCB, we name iterations board1, > board2, etc, and drag the old ones into an OLD folder until it's > done. Spice folders get a OLD sub-folder too. > > Windows batch files don't make a lot of sense to me. Too many > ambiguities. > > For example, > > C:\Protos\Z540_P940_Load_Board\PCB\OLD > > is full of obsolete iterations.
Windows 10 allows one to have a Linux session within windows. Linux batch scripting is far more advanced. It might not like the NTFS thing though. You could use it to establish a list, which a Windows Power Shell batch file then uses for the deletion task.