Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Checking for a file before importing

Featured Replies

I have set up a script to run daily that will import a .csv files that is sent to us by one of our customers (using scriptfire to run them on a schedule). This works great until the customer forgets to post a nightly file. In this case the system sits with an error message until it is manually cleared.

How can I have FM check to see if the file exist prior to attempting the import? If it does exsist then it would continue and do the import and if not it would skip this step and continue.

Thanks

James

I have not tried it so I will ask, did you try an error capture in the script?

To test for a file from the command line with FileMaker use this concept.

Send Event[ CMD /C DIR C:ClientFolderClientFile.csv /B >FileTest.txt ]

Pause 2 seconds

Import the FileTest.txt file into its own table.

If the text "ClientFile.csv" imported, the file exists.

Continue regular script...

Another approach I've used to check to see if a file exists is to use the Import File as reference script step. Then, if that doesn't get an error, continue with the Import Records script. Your path is consistent? How do you know you've gotten the most recent and not yesterday's?

I like the idea of not leaving FileMaker to check if the file exists alot.

To find the date/time information about the file from the command line.

CMD /C DIR C:ClientFolderClientFile.csv /T:W /4 >FileTest.txt

/T:C = Creation

/T:A = Last Access

/T:W = Last Written

Returns:

/? Volume in drive C has no label.

Volume Serial Number is AAAA-1111.

Directory of C:ClientFolder

11/29/2007 03:42 PM 1 ClientFile.csv

1 File(s) 1 bytes

0 Dir(s) 29,285,822,464 bytes free

  • Author

First let me answer the questions so i can provide as much information as posible.

Q. did you try an error capture in the script?

A. I done any error capture in the script and would not exactlly know how to do that.

_________________________________

Q. How do you know you've gotten the most recent and not yesterday's?

A. The file that I am importing is dated at the time of export. I have serit up to change the file name to the new name at the import

p:vdataimport12032007.csv

_________________________________

I have tried the CMD and that seems to work to get the ouutput file, However if the file is not in there the output file is a blank and I get the error "No fileds are defined in the data source"

Is there a way to shut that error off?

Using the tags /t and such I do not get a blank file but I can not really use the data within.

Any sugestions?

Thanks for looking at this and any assistance.

James

James,

Attached is a set of sample files.

Ensure the .csv file names fall within the date range of your testing day and the file path is set for your settings.

Once it works for you, try turning the "Set Error Capture" to off.

vData.zip

  • 2 weeks later...
  • Author

Mark,

I like how that stops the remaining part of the script from running, but I would still need to click the OK button so thst it does not lock the workstation. I am using scriptfire to automate scripts and the problem that I am having is the user intervention that is needed by having to click ok. I would like to get to a point that is logs the activity but does not nees someone to press OK when an error occurs.

Thanks Again for all you help. Sorry it took me so long to test it and get back to you.

James

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.