English Amiga Board


Go Back   English Amiga Board > Support > support.AmigaOS

 
 
Thread Tools
Old 18 March 2024, 02:38   #1
PoulpSquad
Registered User
 
PoulpSquad's Avatar
 
Join Date: Aug 2012
Location: Torelló, Spain
Age: 47
Posts: 93
Question Proper syntax for deleting a bunch of non-empty dirs?

Hello all,


I am trying to delete a bunch of directories by running a script, but I'm always getting the error "directory is not empty".


I've tried selecting and deleting them all in Directory Opus, but I get the same error.


So far, I've been trying this in my script:


delete dh1:Software/Games/A-Train all
delete dh1:Software/Games/A10TankKiller all

delete dh1:Software/Games/AfterBurner88 all
...


or


delete all dh1:Software/Games/A-Train#?
delete all dh1:Software/Games/A10TankKiller#?
delete all dh1:Software/Games/AfterBurner88#?
...


Some help about the proper syntax would be very welcome!


Thank you for your time reading this.



(AmigaOS 3.9)
PoulpSquad is offline  
Old 18 March 2024, 05:38   #2
DisasterIncarna
Registered User
 
DisasterIncarna's Avatar
 
Join Date: Oct 2021
Location: England
Posts: 1,218
i just added those directory names with some random files to my ramdisk and tried your commands, they deleted the directory contents and the directory no problem so not sure why its not working for you? do you maybe have some files with their deletion flag removed? that would cause a fail to delete but it would output that reason to see on shell if that was so.

If the stuff you want deleted all starts with "A" you could try: DELETE A#? ALL
DisasterIncarna is offline  
Old 18 March 2024, 06:04   #3
PoulpSquad
Registered User
 
PoulpSquad's Avatar
 
Join Date: Aug 2012
Location: Torelló, Spain
Age: 47
Posts: 93
Hi DisasterIncarna, thank you for your reply!

Quote:
do you maybe have some files with their deletion flag removed?
I just checked flags in Directory Opus and tried again, with the same results.

Quote:
If the stuff you want deleted all starts with "A" you could try: DELETE A#? ALL
Alas, I need to delete about 230 directories out of 1200, ranging from # to Z.

I could overkill it by preparing a new empty HDF and move everything there except for the stuff I need removed, but I'd rather understand how to use delete...

Edit:

Setting a text file as executable with a series of commands doesn't work as intended:

example
delete dh1:Software/Games/A-Train all
delete dh1:Software/Games/A10TankKiller all
delete dh1:Software/Games/AfterBurner88 all

execute example
delete dh1:Software/Games/A-Train all Not deleted: directory not empty
delete failed returncode 20

Whereas typing the exact same command in a shell will work fine.

Last edited by PoulpSquad; 18 March 2024 at 06:19. Reason: New relevant info
PoulpSquad is offline  
Old 18 March 2024, 06:31   #4
DisasterIncarna
Registered User
 
DisasterIncarna's Avatar
 
Join Date: Oct 2021
Location: England
Posts: 1,218
a pain in the backside, but does deleting the files first then the folder work?

delete dh1:Software/Games/A-Train/#? all
delete dh1:Software/Games/A-Train

delete dh1:Software/Games/A10TankKiller/#? all
delete dh1:Software/Games/A10TankKiller

delete dh1:Software/Games/AfterBurner88/#? all
delete dh1:Software/Games/AfterBurner88

Shouldnt be required but can at least try to narrow down whats going wrong. as for your script, use: Protect Scriptname +s
DisasterIncarna is offline  
Old 18 March 2024, 06:35   #5
PoulpSquad
Registered User
 
PoulpSquad's Avatar
 
Join Date: Aug 2012
Location: Torelló, Spain
Age: 47
Posts: 93
Yes, it does work, I was trying that just now.

delete dh1:Software/Games/A-Train/#? all

deletes all files inside the dir A-Train.

I'd need a second pass to get rid of the directory proper, as you clearly show in your example.

Edit:

Scratch that, works on some dirs, gets stuck on others. I'm at a loss understanding what's going on.
I'll just make a new hdf and copy the stuff I want to keep over, until I get a better understanding of what I'm doing wrong.

Last edited by PoulpSquad; 18 March 2024 at 06:45. Reason: More info
PoulpSquad is offline  
Old 18 March 2024, 07:27   #6
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,348
If DOpus and CLI commands all fail, why not trying with normal WB ?
meynaf is online now  
Old 18 March 2024, 08:16   #7
PoulpSquad
Registered User
 
PoulpSquad's Avatar
 
Join Date: Aug 2012
Location: Torelló, Spain
Age: 47
Posts: 93
Indeed, I've been trying both wb cli and opus, with the same results in both.

I'm moving the files I want to keep, excepting the stubborn few that I can't delete to a new volume. This should defrag everything, which is a nice bonus.
PoulpSquad is offline  
Old 18 March 2024, 08:45   #8
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,348
WB deletes contents of dirs prior to removing them, so if it fails, it's because some files are not deletable for whatever reason. It should also display an error message.
If files have no issue with protection flags, it may be that the file system is damaged in some way. In that case, moving to a new volume is the solution.
meynaf is online now  
Old 18 March 2024, 11:13   #9
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,374
This could be a delayed write / asynchronous action by the filesystem. I see this happening sometimes on partitions that use PFS3 - it doesn't immediately commit the delete (or move to recycling dir) operations to disk, so if you try to delete the directory too soon after deleting the contents (which is what Workbench etc. will do automatically), it finds the directory isn't empty. It doesn't happen for me when using FFS.

This would explain why your script fails while typing the commands manually works - the extra delay allows the delete operation to complete first. As a workaround, you could try adding a short delay between the file delete and dir delete operations using the Wait command.
Daedalus is offline  
Old 18 March 2024, 11:14   #10
mrv2k
Registered User
 
Join Date: Apr 2020
Location: England
Age: 53
Posts: 436
You may need to add the FORCE option on some folders as it overrides the D protection bit on files. e.g.

Code:
delete dh1:Software/Games/AfterBurner88 FORCE ALL
mrv2k is offline  
Old 18 March 2024, 17:13   #11
PoulpSquad
Registered User
 
PoulpSquad's Avatar
 
Join Date: Aug 2012
Location: Torelló, Spain
Age: 47
Posts: 93
Thanks @all for the suggestions, pro tips and ideas!

@meynaf:
Quote:
If files have no issue with protection flags, it may be that the file system is damaged in some way. In that case, moving to a new volume is the solution.
Filesystem is PFS3AIO and appears to be in ok conditions, after checking it with pfsdoctor.
Flags are rwd, applied before running the script.

@Daedalus:
Quote:
This would explain why your script fails while typing the commands manually works - the extra delay allows the delete operation to complete first.
This makes sense and would explain why the script fails. Maybe there is an utility to flush the cache content to the disk, I'll take a look on Aminet.

@mrv2k:
Quote:
You may need to add the FORCE option on some folders as it overrides the D protection bit on files. e.g.
Alas, same result as without FORCE .

Last edited by PoulpSquad; 19 March 2024 at 03:20. Reason: Correct typo
PoulpSquad is offline  
Old 21 March 2024, 20:39   #12
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,264
Quote:
Originally Posted by PoulpSquad View Post
Alas, same result as without FORCE .
We had seen similar effects during the development of 3.1.4 and 3.2. PFS has simply defects. If I recall, it was related to the undelete option, but I do not recall.
Thomas Richter is offline  
Old 23 March 2024, 12:25   #13
PoulpSquad
Registered User
 
PoulpSquad's Avatar
 
Join Date: Aug 2012
Location: Torelló, Spain
Age: 47
Posts: 93
@Thomas Richter:

I am sorry for the delay, I somehow missed the notification and didn't check this thread any further

Quote:
We had seen similar effects during the development of 3.1.4 and 3.2. PFS has simply defects.
Interesting. I just migrated my stuff to a new HDF without any further issues.

It appears my problem only happens when deleting stuff, which seems to confirm your observation.
PoulpSquad is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
symbolic links to dirs are not evaluated when needed boemann support.WinUAE 14 16 September 2022 19:40
Need a fluent scroll in WB dirs VoltureX support.Apps 6 29 November 2011 11:01
Deleting files! Ech0 support.Hardware 7 04 September 2011 14:19
Problem with XPK packed modules dirs QuartZ support.WinUAE 1 29 December 2010 00:39
LZX unarchiver that saves logs and/or removes extracted files/dirs with bad crc oldpx request.Apps 16 15 December 2002 15:57

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:22.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08620 seconds with 15 queries