18 March 2024, 02:38 | #1 |
Registered User
Join Date: Aug 2012
Location: Torelló, Spain
Age: 48
Posts: 93
|
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) |
18 March 2024, 05:38 | #2 |
Registered User
Join Date: Oct 2021
Location: England
Posts: 1,279
|
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 |
18 March 2024, 06:04 | #3 | ||
Registered User
Join Date: Aug 2012
Location: Torelló, Spain
Age: 48
Posts: 93
|
Hi DisasterIncarna, thank you for your reply!
Quote:
Quote:
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 |
||
18 March 2024, 06:31 | #4 |
Registered User
Join Date: Oct 2021
Location: England
Posts: 1,279
|
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 |
18 March 2024, 06:35 | #5 |
Registered User
Join Date: Aug 2012
Location: Torelló, Spain
Age: 48
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 |
18 March 2024, 07:27 | #6 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,365
|
If DOpus and CLI commands all fail, why not trying with normal WB ?
|
18 March 2024, 08:16 | #7 |
Registered User
Join Date: Aug 2012
Location: Torelló, Spain
Age: 48
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. |
18 March 2024, 08:45 | #8 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,365
|
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. |
18 March 2024, 11:13 | #9 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,381
|
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. |
18 March 2024, 11:14 | #10 |
Registered User
Join Date: Apr 2020
Location: England
Age: 53
Posts: 443
|
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 |
18 March 2024, 17:13 | #11 | |||
Registered User
Join Date: Aug 2012
Location: Torelló, Spain
Age: 48
Posts: 93
|
Thanks @all for the suggestions, pro tips and ideas!
@meynaf: Quote:
Flags are rwd, applied before running the script. @Daedalus: Quote:
@mrv2k: Quote:
Last edited by PoulpSquad; 19 March 2024 at 03:20. Reason: Correct typo |
|||
21 March 2024, 20:39 | #12 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,331
|
|
23 March 2024, 12:25 | #13 | |
Registered User
Join Date: Aug 2012
Location: Torelló, Spain
Age: 48
Posts: 93
|
@Thomas Richter:
I am sorry for the delay, I somehow missed the notification and didn't check this thread any further Quote:
It appears my problem only happens when deleting stuff, which seems to confirm your observation. |
|
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 |
|
|