Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete a file on hard drive

214 views
Skip to first unread message

Christoph Kaufmann

unread,
Apr 7, 2012, 9:09:48 AM4/7/12
to
FMP 10: Export field contents deletes the indicated file on the hard
drive if no field is specified.

This may not work because the field has been removed, renamed, or has
become read-only for some reason.

Whatever the case, the script reports error 102 because I didn't
indicate a field (naturally). Any chance for the script to find out
wheter or not we had success? I know the problem can be solved with
plugins, and I will gladly use them if we have to handle a lot of files,
for the time being, I try to get through without plugins in order to
save some goodwill points in our paranoid IT dept.

I could try to import the file into a global container and check for
errors there. Better ways?

--
http://clk.ch

Ursus

unread,
Apr 11, 2012, 3:36:23 AM4/11/12
to

"Christoph Kaufmann" <clkau...@gmx.ch> schreef in bericht
news:1ki6rya.19sapswrzcg5gN%clkau...@gmx.ch...
With both Win and OSx you could use scripting. But you would have to know
the file name and location. WinCMD is more complex, apple script I'm not
proficient...

Win (basic outline)

create textfield, Mypath
Make it set to "cmd dir /b " & path & name of file & " >> test.txt
create script with Send Event ("aevt";"odoc";Mypath) Which is FileType
Unknown,Open document/application/calculation(mypath)
It will create test.txt
Import this into a temp table
If file didn't exist it will say so, if it did it will contain filename and
size.
On both of which you can do a calc to determine whaty happend
If you want it deleted create a similar scipt step
cmd del mypath & myfile

OSx (something like)

create script which excutes an apple script

on error
try
move myfile of mypath of mydisk to trash
end try


Hope this will get you going

Ursus

Christoph Kaufmann

unread,
Apr 11, 2012, 12:44:15 PM4/11/12
to
Ursus <Ursus...@gmail.com> wrote:

> Hope this will get you going

Sounds great, thank you.
--
http://clk.ch

Christoph Kaufmann

unread,
Apr 18, 2012, 9:10:04 AM4/18/12
to
[Windows only]
Problem: Delete a file referenced in a container field.

The script step Export Field Contents deletes the indicated file on
the hard drive if no field is specified. This may not work because the
field has been removed, renamed, or has become read-only for some
reason.

Ursus wrote:

> With both Win and OSx you could use scripting. But you would have to know
> the file name and location. WinCMD is more complex, apple script I'm not
> proficient...
>
> Win (basic outline)

Worked at last; thanks agagin.

> create textfield, Mypath
> Make it set to "cmd dir /b " & path & name of file & " >> test.txt
> create script with Send Event ("aevt";"odoc";Mypath) Which is FileType
> Unknown,Open document/application/calculation(mypath)
> It will create test.txt

I couldn't get it to work with this syntax. Here's what worked on my
XP system [1]:

cmd /c echo $content > "$dosPath"

where $content is the contents of the file and $dosPath is the
complete path, starting with "C:\" or something, ending with the file
name.

> Import this into a temp table
> If file didn't exist it will say so

This one gave me a headache: if the test file was successfully
written, the script told me so and deleted it - but only when I
debugged the script. When running normally, the script successfully
wrote the file, but it seems the import failed.

After checking maybe eleven times with and without debug, I decided
the delay must have been critical - inserting a script pause of 3 sec
between file write and import did it, and it still works with a pause
of 0.05 sec (same machine, same volume; network might be different).

So we have a way to find out whether or not we're allowed to write
files in a directory. Weak points:
a) we assume if we can write we can delete. Probably true in almost
every case
b) We don't know wheter the file we want to delete is still there, and
its name
c) we don't know whether the file is open or write-protected

So if you're up to efficiency and fool prof solutions rather than
experimenting, Troi file migth be the better choice. Or an upgrade to
Filemaker 12 which appears to have some more functionality.

After all the time I've spent exploring this, I intend to use the
solution outlined by Ursus in in our Filemaker 10 solution until we
upgrade to Filemaker 13.

[1] influenced by
http://www.filemakertoday.com/com/entry.php/18-Creating-a-Folder-from-FileMaker-(Windows)
--
Viele Grüsse
Christoph Kaufmann
http://clk.ch
0 new messages