16 September 2017, 07:50 | #1 |
Registered User
Join Date: Mar 2016
Location: Yes
Posts: 14
|
AmigaDOS script: Replacing characters and checking if directory is empty
Hi everyone.
A couple of AmigaDOS shell scripting questions: 1. Is it possible to escape a filename or directory name? eg. Instead of "Example#File.txt", it can be escaped to "Example'#File.txt". I can't think of any way of doing string substitution. 2. Is it possible to check if a directory is empty? Thanks! |
16 September 2017, 14:17 | #2 |
Registered User
Join Date: Oct 2009
Location: Germany
Posts: 3,325
|
1. Use Arexx. Maybe there is a way doing it in DOS but I don`t know.
2. "list Ram:Clipboards/" outputs: Directory "Ram:Clipboards/" is empty. If you examine this you should be able to check for empty dirs. Or use Arexx. |
16 September 2017, 14:53 | #3 |
Registered User
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
|
some aminet tools may help:
CheckEmpty V1.4 - Checks if a directory is empty list of tools matching string. |
17 September 2017, 17:18 | #4 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,377
|
1. You almost wrote the solution yourself. An apostrophe will escape a wildcard character. This I never knew, but the AmigaDOS manual does state it:
http://wiki.amigaos.net/wiki/AmigaOS...DOS_Characters |
24 September 2017, 19:40 | #5 |
Registered User
Join Date: Mar 2016
Location: Yes
Posts: 14
|
I don't want to use Arexx :P
I'd already messed with listing a directory and checking for output, but things became complicated when the directory didn't exist. Anywho, CheckEmpty did what I want (thanks emufan!). I'd already checked Aminet for string tools but nothing does exactly what I want, so I wrote it in C Thanks guys! |
29 March 2024, 20:24 | #6 | |
Registered User
Join Date: May 2020
Location: Figueira da Foz
Posts: 460
|
Quote:
I try to do something like this Code:
ce ce >nil: if warn echo option a endif if error echo option b endif if fail echo option c endif |
|
29 March 2024, 22:22 | #7 |
Registered User
Join Date: Dec 2017
Location: US
Posts: 9
|
Add
FailAt 50 to the top of the script. By default, it is 10. |
30 March 2024, 09:35 | #8 |
Registered User
Join Date: May 2020
Location: Figueira da Foz
Posts: 460
|
|
30 March 2024, 11:02 | #9 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 44
Posts: 962
|
Two issues:
1. Running a command will overwrite the result code stored in local env RC from ce. Command for example is If. So the next If checks RC from previous command which is If. 2.WARN matches RC greater or equal to 5, ERROR greater or equal to 10 and so on, so even if 1. Was not an issue, if you got RC 10, it would match the two first If clauses. Instead, after the ce line, save RC in a local env variable so you can keep the value over several if checks and compare against the exact values you are interested in in the If’s. Last edited by patrik; 30 March 2024 at 11:15. |
30 March 2024, 11:53 | #10 |
Registered User
Join Date: May 2020
Location: Figueira da Foz
Posts: 460
|
nice, didn't knew the error code was passed through $rc. It helps a lot
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AmigaDos script help | liviux76 | Coders. Scripting | 8 | 09 November 2017 16:20 |
Checking for genuine CPUs? | Mr.Flibble | support.Hardware | 0 | 03 July 2015 21:08 |
Changing date/timestamp of AmigaDOS directory? | rhester72 | support.Apps | 1 | 27 May 2015 23:42 |
AmigaDos script file help. | T_hairy_bootson | support.Apps | 0 | 07 March 2006 10:15 |
Checking my Religion | Axxy | request.Modules | 0 | 04 July 2005 19:22 |
|
|