|
Home > Archive > Unix Shell > February 2007 > Getting file version
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Getting file version
|
|
| dantes990@yahoo.com 2007-02-14, 1:20 pm |
| I want to write a script to get the versions for all the files in a
directory, then output this info (file name and version) to a text
file. Seems like there should be a command or at least simple way to
do this, but I am not finding one. This script will be running from
terminal on OS X and typically I've scripted using the bourne shell
before, but I am open to any ideas. Any help is appreciated.
| |
| Anderson Deluiz 2007-02-14, 7:21 pm |
| On 14 fev, 16:58, dantes...@yahoo.com wrote:
> I want to write a script to get the versions for all the files in a
> directory, then output this info (file name and version) to a text
> file. Seems like there should be a command or at least simple way to
> do this, but I am not finding one. This script will be running from
> terminal on OS X and typically I've scripted using the bourne shell
> before, but I am open to any ideas. Any help is appreciated.
Output all info to a file and get all files in a directory is easy.
The problem is: how do you know the way to get file version ?
If it is a executable, the -V or -v flag may exist. But, if it is a
text file or any other binary data file, how to do that ?
Regards
| |
| Chris F.A. Johnson 2007-02-14, 7:21 pm |
| On 2007-02-14, dantes990@yahoo.com wrote:
> I want to write a script to get the versions for all the files in a
> directory, then output this info (file name and version) to a text
> file. Seems like there should be a command or at least simple way to
> do this, but I am not finding one. This script will be running from
> terminal on OS X and typically I've scripted using the bourne shell
> before, but I am open to any ideas. Any help is appreciated.
for file in *
do
printf "%s: " "$file"
: whatever command gets you the version
done > version_file
Many files do not have a version, so use whatever command works
for the files in question.
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
| |
| dantes990@yahoo.com 2007-02-14, 7:21 pm |
| On Feb 14, 11:44 am, "Chris F.A. Johnson" <cfajohn...@gmail.com>
wrote:
> On 2007-02-14, dantes...@yahoo.com wrote:
>
> for file in *
> do
> printf "%s: " "$file"
> : whatever command gets you the version
> done > version_file
>
> Many files do not have a version, so use whatever command works
> for the files in question.
>
> --
> Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> ===== My code in this post, if any, assumes the POSIX locale
> ===== and is released under the GNU General Public Licence
That's helpful, but the thing I am really struggling with is what
command to use to get the file version. Does anyone know?
Even something that dumps all file info about a file to a text file,
then parse the file for the version is fine. All the files are the
same type and have a version... Just don't know what command to use to
gather that info.
| |
| Phil Jackson 2007-02-14, 7:21 pm |
| dantes990@yahoo.com writes:
> On Feb 14, 11:44 am, "Chris F.A. Johnson" <cfajohn...@gmail.com>
>
> Even something that dumps all file info about a file to a text file,
> then parse the file for the version is fine. All the files are the
> same type and have a version... Just don't know what command to use to
> gather that info.
We (I) don't know what you mean by "file versions". Are they in a
revision control system? Are you using some fancy filesystem?
Give us an example of what you would expect to see and we might be able
to help you.
Phil
--
"Can you get a ticket for running a stop sign that is not
there?"
- Driver school applicant
| |
| Chris F.A. Johnson 2007-02-14, 7:21 pm |
| On 2007-02-14, dantes990@yahoo.com wrote:
> On Feb 14, 11:44 am, "Chris F.A. Johnson" <cfajohn...@gmail.com>
> wrote:
>
> That's helpful, but the thing I am really struggling with is what
> command to use to get the file version. Does anyone know?
>
> Even something that dumps all file info about a file to a text file,
> then parse the file for the version is fine. All the files are the
> same type and have a version... Just don't know what command to use to
> gather that info.
What information do you want? What type of files are they? Do they
even have versions (many, if not most, don't)?
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
| |
| dantes990@yahoo.com 2007-02-14, 7:21 pm |
| On Feb 14, 2:59 pm, "Chris F.A. Johnson" <cfajohn...@gmail.com> wrote:
> On 2007-02-14, dantes...@yahoo.com wrote:
>
>
>
>
>
> What information do you want? What type of files are they? Do they
> even have versions (many, if not most, don't)?
>
> --
> Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> ===== My code in this post, if any, assumes the POSIX locale
> ===== and is released under the GNU General Public Licence
Maybe I am barking up the wrong tree here... I suppose I should be in
an OS X users group, but I was hoping to write this in the bourne
shell since it is the only one I have any experience with. Anyway...
This is going to be (hopefully) a simple script to run on the OS X
terminal. I basically just want to be able to get the version info
that you get when you run "Get Info" on a file thru the GUI in OS X.
I am assuming the version info would be the same regardless of whether
or not it was in the OSX GUI or from within a Unix shell in Terminal.
Is there a way to get this same version info from the terminal on OS
X?
Is there a simple way to do this from the terminal, I want to be able
to dump this version info to a text file.
| |
| Chris F.A. Johnson 2007-02-14, 7:21 pm |
| On 2007-02-14, dantes990@yahoo.com wrote:
> On Feb 14, 2:59 pm, "Chris F.A. Johnson" <cfajohn...@gmail.com> wrote:
>
> Maybe I am barking up the wrong tree here... I suppose I should be in
> an OS X users group, but I was hoping to write this in the bourne
> shell since it is the only one I have any experience with. Anyway...
It makes no difference which shell you use. You need a command
which get you the info you want; any shell will be able to run it.
> This is going to be (hopefully) a simple script to run on the OS X
> terminal. I basically just want to be able to get the version info
> that you get when you run "Get Info" on a file thru the GUI in OS X.
> I am assuming the version info would be the same regardless of whether
> or not it was in the OSX GUI or from within a Unix shell in Terminal.
>
> Is there a way to get this same version info from the terminal on OS
> X?
Only if OS/X provides a command to do it.
> Is there a simple way to do this from the terminal, I want to be able
> to dump this version info to a text file.
If there is no command to do what you want, you will have to write
one. Or get someone else to write one, and to do that you will
neeed to provide information on the file format. (Doesn't the Mac
use a second file with meta information about the file?)
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
| |
| dantes990@yahoo.com 2007-02-14, 7:21 pm |
| On Feb 14, 3:52 pm, "Chris F.A. Johnson" <cfajohn...@gmail.com> wrote:
> On 2007-02-14, dantes...@yahoo.com wrote:
>
>
>
>
>
>
>
> It makes no difference which shell you use. You need a command
> which get you the info you want; any shell will be able to run it.
>
>
>
> Only if OS/X provides a command to do it.
>
>
> If there is no command to do what you want, you will have to write
> one. Or get someone else to write one, and to do that you will
> neeed to provide information on the file format. (Doesn't the Mac
> use a second file with meta information about the file?)
>
> --
> Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> ===== My code in this post, if any, assumes the POSIX locale
> ===== and is released under the GNU General Public Licence
Yeah, I think the version info from Get Info is coming from the
resource fork... . I may need to post this in an OS X group to see if
there is all ready a tool for this. Thanks for the help so far!
| |
| Alexander Skwar 2007-02-15, 1:19 pm |
| <dantes990@yahoo.com>:
> I want to write a script to get the versions for all the files in a
> directory,
What's a "version"? What do you mean with that?
> then output this info (file name and version) to a text
> file. Seems like there should be a command or at least simple way to
> do this, but I am not finding one.
General approach:
find $dir -exec $command_to_get_version {} \; > text_file
Alexander Skwar
| |
| Eric van der Meer 2007-02-18, 1:18 pm |
| In article <dujca4-jt.ln1@xword.teksavvy.com>, cfajohnson@gmail.com wrote:
> On 2007-02-14, dantes990@yahoo.com wrote:
>
> It makes no difference which shell you use. You need a command
> which get you the info you want; any shell will be able to run it.
>
>
> Only if OS/X provides a command to do it.
>
>
> If there is no command to do what you want, you will have to write
> one. Or get someone else to write one, and to do that you will
> neeed to provide information on the file format. (Doesn't the Mac
> use a second file with meta information about the file?)
Hi,
AFAIK on MacOS X only applications have a version. One way to get this
information from the command line is to look inside the application. At
the Unix level every application is a directory. E.g. iTunes is located in
the directory /Applications/iTunes.apps. The version information is kept
in the file /Applications/iTunes.app/Contents/Info.plist; look at the line
after the one with CFBundleGetInfoString. Scripting the lookup should not
be too difficult.
HTH,
Eric
|
|
|
|
|