• 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: Script to replace lost file extension
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script to replace lost file extension


  • Subject: Re: Script to replace lost file extension
  • From: Wayne Melrose <email@hidden>
  • Date: Tue, 24 Apr 2007 11:27:45 +0200


On 24/04/2007, at 11:14 AM, Simon, Garry wrote:

Hello, does anyone know if a script could be used to examine a file that has no extension, and determine what its extension should be? At my job we frequently receive files that have lost their extensions, and need to restore them. There must be a shell script that can determine what a file’s extension was.

 

Thanks,

Garry Simon

 
 

I'll speak for myself but.. . We deal with the same issues, files can sometimes get damaged in transfer as it is. Sometimes even correcting the file extension does not solve the problem. This is where the 'ole right click (ctrl click) "Create archive ..." instruction is always the best solution.. OK so it requires re-sending a file on behalf of the sender, although it's good practice anyway. 

I know that 
do shell script "head -1 /path/to/file" 
will return the first line of file without opening the whole thing. A pdf file with no extension will give you the result %????1.6

A PDF file always starts with %PDF1.6  so that might be a tip to have a look at what else you can find. Or start a discussion on a MUCH smarter way to go about this ;) 

Wayne.. 

 _______________________________________________
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: Script to replace lost file extension
      • From: Emmanuel <email@hidden>
    • Re: Script to replace lost file extension
      • From: "Steven D. Majewski" <email@hidden>
References: 
 >Script to replace lost file extension (From: "Simon, Garry" <email@hidden>)

  • Prev by Date: Script to replace lost file extension
  • Next by Date: Re: Script to replace lost file extension
  • Previous by thread: Script to replace lost file extension
  • Next by thread: Re: Script to replace lost file extension
  • Index(es):
    • Date
    • Thread