in reply to removing directories with wildcard glob in OS-portable way
Please tell me I'm over-thinking this!
You're over thinking this! :) Or rather, going about things the hard way.
Assuming the command you gave does what you need everywhere bar Windows, just use this when you detect Windows:
system qq[ for /d %d in ($tmp\\scale-*) do @rd /q /s %d ];
Eg:
C:\test>dir /b /s ppp C:\test\ppp\donttouch C:\test\ppp\scale-123 C:\test\ppp\scale-124 C:\test\ppp\scale-125 C:\test\ppp\donttouch\junk.1 C:\test\ppp\scale-123\junk C:\test\ppp\scale-123\junk\junk.1 C:\test\ppp\scale-123\junk\junk.2 C:\test\ppp\scale-123\junk\junk.3 C:\test\ppp\scale-124\junk C:\test\ppp\scale-124\junk\junk.1 C:\test\ppp\scale-124\junk\junk.2 C:\test\ppp\scale-124\junk\junk.3 C:\test\ppp\scale-125\junk C:\test\ppp\scale-125\junk\junk.1 C:\test\ppp\scale-125\junk\junk.2 C:\test\ppp\scale-125\junk\junk.3 C:\test>for /d %d in (ppp\scale-*) do rd /q /s %d C:\test>rd /q /s ppp\scale-123 C:\test>rd /q /s ppp\scale-124 C:\test>rd /q /s ppp\scale-125 C:\test>dir /b /s ppp C:\test\ppp\donttouch C:\test\ppp\donttouch\junk.1
Why reinvent an operation that the OS already knows how to do?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: removing directories with wildcard glob in OS-portable way
by Anonymous Monk on Dec 30, 2012 at 00:32 UTC | |
by BrowserUk (Patriarch) on Dec 30, 2012 at 01:15 UTC | |
by Anonymous Monk on Dec 30, 2012 at 03:53 UTC |