Page 1 of 1

Filesize and filenames with brackets

Posted: Sun Dec 22, 2019 3:05 am
by daveyw
Hi all,

I am currently working on an arexx script that uses filesize. However, I'm finding that, even with quotes, it doesn't like filenames with brackets.

For example,

Code: Select all

filesize "SMBFS0:Temp/Avengers.Endgame.2019" format %L
results in "3,219,186,473".

However,

Code: Select all

filesize "SMBFS0:Temp/Avengers.Endgame(2019)" format %L
results in nothing - in my script which does >T:FS1, the result is an empty file, and in a shell, the result is nothing returns.

Has anyone encountered this before? Is there a workaround?

Thanks for any info.

Re: Filesize and filenames with brackets

Posted: Sun Dec 22, 2019 10:44 am
by tonyw
I'll just delete what I wrote as it is rubbish.

I see that testing such a file name in RAM: and an NGFS volume shows the same fault. I'll get Colin onto this...

Meantime, the file is stored on the volume with the right name (including the parentheses) and if you list the directory, the file appears.
I created a file in RAM:called "Avengers(2019)". If I "list RAM:, the file appears with its name intact, but you can't access it by name. You CAN access it by typing "type RAM:#?", so you may have some luck that way.

Re: Filesize and filenames with brackets

Posted: Sun Dec 22, 2019 12:00 pm
by thomasrapp
Brackets are wildcard characters. The program will list the directory SMBFS0:Temp and find all files which match the wildcard pattern. In this case the only match would be a file called Avengers.Endgame2019. It does not exist, hence the output is empty.

If you need to use brackets in file names, you have to escape them with the ' charater.

This should work:

Code: Select all

filesize "SMBFS0:Temp/Avengers.Endgame'(2019')" format %L

Re: Filesize and filenames with brackets

Posted: Mon Dec 23, 2019 4:39 am
by daveyw
Thanks for the reply. This seems odd - it's not listed as a wildcard.

Since this is a script, I would need to write a function that searches the filename string character by character, and insert ' before every bracket?

Re: Filesize and filenames with brackets

Posted: Mon Dec 23, 2019 10:02 am
by BandiT
thomasrapp wrote:Brackets are wildcard characters. The program will list the directory SMBFS0:Temp and find all files which match the wildcard pattern. In this case the only match would be a file called Avengers.Endgame2019. It does not exist, hence the output is empty.

If you need to use brackets in file names, you have to escape them with the ' charater.

This should work:

Code: Select all

filesize "SMBFS0:Temp/Avengers.Endgame'(2019')" format %L

I have also noticed this when using the version command. On RadeonHD(3) for example, it wont return the version. Delete the (3) and it works fine on the same file.

Is that intended use?

Regards
Anthony

Re: Filesize and filenames with brackets

Posted: Mon Dec 23, 2019 10:19 am
by nbache
daveyw wrote:Thanks for the reply. This seems odd - it's not listed as a wildcard.
https://wiki.amigaos.net/wiki/Pattern_Matching:

"()
Parentheses group special characters. The expression within the parentheses is a subpattern."


It's probably technically wrong to call them wildcards, but they are interpreted as having a role in pattern matching before being seen as the parenthesis characters themselves.
Since this is a script, I would need to write a function that searches the filename string character by character, and insert ' before every bracket?
In ARexx, you do have a few shortcuts over the simple looping over all characters - you can use pos() and overlay() etc., although you'd still have to loop until you don't find any more parentheses/end of string - but in pure ARexx there is unfortunately no direct function for replacing all occurrences of one character with a string of two. There is probably something in one of the helper libraries (rexxtools, rmh etc.), but I don't remember it specifically.

Best regards,

Niels