• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: constructing file name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: constructing file name


  • Subject: Re: constructing file name
  • From: Graff <email@hidden>
  • Date: Sun, 22 Feb 2004 22:30:03 -0500

I'm all for using a bit of shell scripting when you really need it but I think it's best to stay away from it for trivial matters. I think that here you are better off just using the date functions built into AppleScript:
-------------
set today to current date
-- the next line formats the date into an integer with yyyymmdd format
set dateInt to ((year of today) * 10000) + (((month of today) as integer) * 100) + (day of today)
set remote_filename to "" & dateInt & "-da.csv"
-------------

- Ken

On Feb 22, 2004, at 9:36 PM, Andrew Oliver wrote:

It sounds to me like you're making this more complex than it needs to be.

You don't exactly say how you're downloading the file, but I'll assume http,
although any other standard URL should work.

If that's the case, you can just:

set remote_filename to (do shell script "date +%Y%m%d") & "-da.csv"

tell application "URL Access Scripting"
download ("http://some.server.net/path/to/"; & remote_filename) to file
"Macintosh HD:da.csv" replacing yes.
end tell

This takes care of all the issues you raise. It lets you specify the local
filename without having to download and rename, and it lets you put it in a
standard location so FileMaker can find it. Additionally, the 'replacing
yes' means you don't have to worry about cleaning up afterwards.

On 2/22/04 5:09 PM, "Mike Bautsch" <email@hidden> wrote:

I need to construct an applescript to automate the download of a file
to be imported into a filemaker database on a daily basis. I am very
familiar with the process of importing into filemaker with applescript
but I am not familiar enough with applescript to construct the name of
the file based on the date and then changing the name of the file
downloaded to a name that will always be the same so filemaker can grab
it.

The file name to be downloaded is always based on tomorrows date. So if
todays date is 2/22/2004 the file name would be "20040222-da.csv". I'm
sure I can use fetch with applescript to do the actual download once
the name is in the proper format. Then I will need to change the name
of the file to something specific such as, "da.csv" so filemaker can
recognize it. Then delete the file so the space is ready for the next
days download. I'm not really sure how to accomplish any of this except
the doscript command to filemaker and using cron to schedule the
applescript to run. All of this will be done in OSX 10.2.8.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: constructing file name (From: Andrew Oliver <email@hidden>)

  • Prev by Date: Re: FileMaker every record whose clause
  • Next by Date: Re: constructing file name
  • Previous by thread: Re: constructing file name
  • Next by thread: Re: constructing file name
  • Index(es):
    • Date
    • Thread