• 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
Rép: Name of file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rép: Name of file


  • Subject: Rép: Name of file
  • From: KOENIG Yvan <email@hidden>
  • Date: Fri, 11 Jan 2008 18:16:08 +0100

Le 11 janv. 2008 à 17:15, demski a écrit :


Am 11.01.2008 um 16:49 schrieb KOENIG Yvan:

set thecsvfile to (choose file with prompt "Wählen Sie die CSV- Datei:" of type {"TEXT"}) as alias

tell application "Finder"
	try
		set xt to name extension of thecsvfile
		set nn to name of thecsvfile
		set nn to text 1 thru -((length of xt) + 2) of nn
		set name of thecsvfile to nn
	end try
end tell

I had just hacked in my (worse) solution, as your answer arrived, yvan...
But, I have a little question here:
shouldn't there be
set nn to text 1 thru -((length of xt) + 1) of nn --< +1 instead of 2 ??


when I try it, there seems to be always the last letter missing...

Am I blind to something?

I guess that you hardcoded the name extension assuming that it is ".csv"
but the one returned by the Finder doesn't contain the period character so it is "csv".


So, as the index of the last character of a string is -1, we must substract 2 to remove the period as well as "csv".

Of course, if you don't want to ask the Finder to get the extension you may use the alternate formula.

I prefer adhere to the standard established by the Finder.
After all, an Applescript saved as a text document has the "applescript" extension and your code let the user select such a file.


Yvan KOENIG

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Rép: Name of file
      • From: demski <email@hidden>
    • Re: Rép: Name of file
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: Re: underscore and splitting words from string...
  • Next by Date: Re: Rép: Name of file
  • Previous by thread: AS Library and dictionary
  • Next by thread: Re: Rép: Name of file
  • Index(es):
    • Date
    • Thread