Delete all files but keep subdirectories

A forum for general AmigaOS 4.x support questions that are not platform-specific

Re: Delete all files but keep subdirectories

Postby softwarefailure » Thu Mar 22, 2018 5:08 pm

@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...
softwarefailure
 
Posts: 91
Joined: Fri Feb 14, 2014 11:29 pm

Re: Delete all files but keep subdirectories

Postby Raziel » Thu Mar 22, 2018 8:07 pm

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 :-)
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
User avatar
Raziel
 
Posts: 795
Joined: Sat Jun 18, 2011 5:00 pm
Location: A haunted Castle somewhere in the Bavarian Mountains

Re: Delete all files but keep subdirectories

Postby softwarefailure » Thu Mar 22, 2018 10:42 pm

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.
softwarefailure
 
Posts: 91
Joined: Fri Feb 14, 2014 11:29 pm

Previous

Return to General AmigaOS

Who is online

Users browsing this forum: No registered users and 5 guests