Delete all files but keep subdirectories

A forum for general AmigaOS 4.x support questions that are not platform-specific
softwarefailure
Posts: 104
Joined: Fri Feb 14, 2014 10:29 pm

Re: Delete all files but keep subdirectories

Post by softwarefailure »

@broadblues:
Thanks, this works fine from a shell on MorphOS but it doesn't work from a makefile. When doing something like this:

Code: Select all

clean:
    list files LFORMAT "DELETE %s%s" dir1 TO PIPE:mypipe | execute PIPE:mypipe
    list files LFORMAT "DELETE %s%s" dir2 TO PIPE:mypipe | execute PIPE:mypipe
    list files LFORMAT "DELETE %s%s" dir3 TO PIPE:mypipe | execute PIPE:mypipe
Only the first command works. The second and third will fail with "EXECUTE: Can't open PIPE:mypipe. Object is in use".

When executing all three lines from a shell, however, it works fine. Well, I guess I should bug the MorphOS guys about it...
User avatar
Raziel
Posts: 997
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: Delete all files but keep subdirectories

Post by Raziel »

The makefile won't be created everytime you build your project, i presume? (and even if, you could probably easily alter the creation of your clean: lines)

So why not do a specific line for every dir you are processing?

Code: Select all

clean:
    list files LFORMAT "DELETE %s%s" dir1 TO PIPE:mypipe | execute PIPE:mypipe
    list files LFORMAT "DELETE %s%s" dir2 TO PIPE:mypipe2 | execute PIPE:mypipe2
    list files LFORMAT "DELETE %s%s" dir3 TO PIPE:mypipe3 | execute PIPE:mypipe3
I'm not using MOS, but it sounds like the pipe you created isn't freed/unlocked after it was executed/used/locked from a makefile/batch script.
That, of course, is a simple guess :-)
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
softwarefailure
Posts: 104
Joined: Fri Feb 14, 2014 10:29 pm

Re: Delete all files but keep subdirectories

Post by softwarefailure »

MorphOS team says it's not allowed to use non-ixemul programs in makefiles so I'm now doing

Code: Select all

find dir1 -type f -maxdepth 1 -exec rm -f {} \; 
find dir2 -type f -maxdepth 1 -exec rm -f {} \; 
find dir3 -type f -maxdepth 1 -exec rm -f {} \; 
instead. On OS4 I can probably use the version suggested by broadblues. I still need to check that.
Post Reply