Filesize and filenames with brackets

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
User avatar
daveyw
Posts: 237
Joined: Mon Sep 12, 2011 7:44 pm

Filesize and filenames with brackets

Post 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.

User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1433
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: Filesize and filenames with brackets

Post 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.
cheers
tony

User avatar
thomasrapp
Posts: 286
Joined: Sat Jun 18, 2011 11:22 pm

Re: Filesize and filenames with brackets

Post 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

User avatar
daveyw
Posts: 237
Joined: Mon Sep 12, 2011 7:44 pm

Re: Filesize and filenames with brackets

Post 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?

User avatar
BandiT
Beta Tester
Beta Tester
Posts: 58
Joined: Mon Dec 20, 2010 1:12 pm
Location: Melbourne, Australia

Re: Filesize and filenames with brackets

Post 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
AmigaOne X1000, Boing Ball Fractal R3 white case, XFX Radeon 4890 XXX edition 1 GB, OCZ Vertex 3 SSD & 1TB Sata HD, AmigaOne Keyboard and
Boing Ball mouse (white), 4 GB Kingston HyperX RAM, Official DVD burner. CoolerMaster GX750, Realtek 8169 (Netgear GA311), BenQ 24" Widescreen.

User avatar
nbache
Beta Tester
Beta Tester
Posts: 1461
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Filesize and filenames with brackets

Post 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

Post Reply