Scodigo, Inc.

Log In | Register

Cart Items:
0

Path to mySolution.fp7

Hello

I would like to rename a (backup-)file that is in the same directory as the FileMaker-solution "mySolution.fp7" using
PHP_Execute( "rename('oldName.fp7','newName.fp7');" )

I get:
PHP Warning: rename(oldName.fp7, newName.fp7) [function.rename]: No such file or directory in Embedded code on line 1

but the file is there, so I suppose the path is wrong.

How do I get and set the correct path?

Thank You

Path to mySolution.fp7

Micah Woods's picture

Hi,

You should be able to solve this issue by including the complete file path to these files. I've written some code that will dynamically calculate the path to the directory where your FileMaker file is running and then use that path in the 2 parameters given to the rename function. I've tested this on both platforms and it seems to work fine.

Let (
[
filePath = Get ( FilePath ) ;
strippedFilePath =
// branch for platform
If ( Abs ( Get ( SystemPlatform ) ) = 1 ; // Mac
Right ( filePath ; Length ( filePath ) - Position ( filePath ; "/" ; 1 ; 2 ) + 1 ) ;
//else
Right ( filePath ; Length ( filePath ) - 6 )
) ;
slashCount = PatternCount ( strippedFilePath ; "/" ) ;
fileFolderPath = Left ( strippedFilePath ; Position ( strippedFilePath ; "/" ; 1 ; slashCount ) ) ;
oldName = fileFolderPath & "oldName.fp7" ;
newName = fileFolderPath & "newName.fp7" ;
phpCode = "If (rename('" & oldName & "', '" & newName & "')) { echo 'The file was successfully renamed.'; } else {echo 'The file rename failed.'; }"

] ;
PHP_Execute( phpCode )
)

Hope this helps. I think we'll eventually release some custom functions that make this even easier. Let me know if you have any more questions.

Regards,
Micah

Hi Micah thank you for your

Hi Micah

thank you for your answer.
I understand your solution, but I can not bring it to work.
Since I'm working on a german system, maybe I have some troubles translating your code.
Could you send the code in a fp7 file, then FileMaker will do the translation for me ;-)

Regards
René

A FileMaker file is on it's

Micah Woods's picture

A FileMaker file is on it's way via email...

-- Micah