Windows batch file help

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.

Reply to
John Larkin
Loading thread data ...

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

Reply to
Joe Gwinn

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

Reply to
Martin Rid

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.

Reply to
John May

søndag den 25. december 2022 kl. 17.04.20 UTC+1 skrev John Larkin:

formatting link
?

Reply to
Lasse Langwadt Christensen

Yikes. Maybe I'll just have someone do it.

I could write a PowerBasic program, I guess.

Reply to
John Larkin

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.

Reply to
Cydrome Leader

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

Reply to
Ricky

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.

Reply to
Martin Brown

John Larkin snipped-for-privacy@highlandSNIPMEtechnology.com wrote in news: snipped-for-privacy@4ax.com:

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.

Reply to
DecadentLinuxUserNumeroUno

mandag den 26. december 2022 kl. 19.39.18 UTC+1 skrev snipped-for-privacy@decadence.org:

WSL is fully integrated with windows, just cd to \mnt\c in linux

Reply to
Lasse Langwadt Christensen

maybe use a port of GNU find.

formatting link
"C:\path_to\find.exe C:\Protos -name OLD -type d -delete"

Reply to
Jasen Betts

Use Total Commander. To a "Search", feed the results back to the active window, Delete

Reply to
Klaus Vestergaard Kragelund

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.