Re: Script to replace lost file extension
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