ExifTool > Newbies

Getting started: Command-line ExifTool in Windows

(1/3) > >>

Phil Harvey:
Feel free to add to this thread with any specific examples you may find useful. (But I reserve the right to edit posts in this thread if necessary to improve accuracy and clarity.)

Here are the basic steps to get started running ExifTool from the command line in Windows:

1) Follow these intructions to install ExifTool for command line use.

2) Click the Windows "Start" menu and run the "cmd" application.


* In Windows 7, search for "cmd" from the "Start" menu, then press RETURN.
* In Windows XP, select "Run..." from the start menu, then type "cmd" and press RETURN.


3) Type ExifTool commands in the cmd window that appears.



A basic ExifTool command looks something like this:

    exiftool c:\pictures\image.jpg

This command will display the metadata from the specified image.  Instead of typing the file name in the command above, you may drag and drop the file onto the cmd window.  The steps would be:

a) Type "exiftool" (without the quotes), then press SPACE.

b) Drag and drop an image file onto the cmd window.

c) Press RETURN in the cmd window.

You can also use ExifTool to read and write specific metadata.  Here is a screen shot of a cmd window showing an example ExifTool session where some specific tags are extracted from all images in the current directory (the current directory is represented by a "." on the command line), and the EXIF Artist tag is updated for one of the images:



- Phil

Tarn:
Instead of clicking on Start, then Run, then typing in "cmd" and clicking on OK, or pressing enter, then changing the drive and directory; create a shortcut on your desktop.

Simply enter the drive and path you would like the window to open up in where it says "Start In:" Click on the "General" tab if you want to change the name of the shortcut (the label that you see on your desktop, not the name of the program.

The example below opens up in U:\images every time.

  Enjoy

terrypin:
Or install this Microsoft PowerToy:
http://download.cnet.com/Open-Command-Window-Here/3000-2094_4-10628470.html

That places an entry, Open Command Window Here, in the Explorer right click context menu. So typically two clicks does the job from anywhere.

--
Terry, East Grinstead, UK

Tarn:
Welcome to
DOS For Dummies
Everything You’ve NEVER Wanted to Know About DOS     (Imagine this part centered as a header)

    This primer is intended for those who know nothing about DOS, the Command Line, or Dos Commands. It is intended for those who have mastered Dos commands, but just want to see what I have to say. And it is intended for everyone in between.

    It is not intended to be the ultimate authority on the subject and, as such, may not include every possible command. It is not intended to make you an expert in DOS (Unless you are, already, an expert).

    SKIP this entire section if you already know, or just don’t care about a brief history of DOS.
   The term DOS stood (stands) for “Disk Operating System”. Long, long ago, the OS (Operating System) for any computer was encoded on a chip inside the computer. Updating your OS required one of two things.
a)   Take your computer into the shop and have them replace, or reprogram, the chip.
b)   Buy a newer computer with the updated OS.
Neither way was very appealing, and both took time and money.
   Then someone came up with the idea: “Why don’t we put the OS on a disk?”. And DOS was born!
        Now, only the basic instructions that were necessary to get the computer up and ready to read the OS from the disk was left on the computer; everything else came from the disk. A major step in computer evolution had been taken with this new Disk based Operating System.

   I offer this brief, abridged, history to make a simple point. And that is look at the last two letters of the acronym… “OS”; Operating System. That’s right! DOS was how computers worked before Windows. I point this out in the hopes of helping you realize the power of DOS.
   Many people will argue that Windows IS an operating system; and for the most part, it is. However, I like to tell people that Windows is a GUI for DOS. Most everything that is done in Windows can be done in DOS. When you open the “cmd window”, instead of “running a program in Windows”, you are “removing the Windows GUI from DOS”. (That’s got some people grinding their teeth right now, I’m sure of it)

   The overall reason for this boring section is to try and get people to relax around DOS. It is powerful, yet simple. Nothing to be feared. Granted, doing things from the Dos prompt (Command Line) is more cumbersome. You need to type things instead of just clicking on icons with your mouse. But the use of .bat (batch) files, or .cmd (command) files can make short work of that typing.

   So next time you open the command window, relax… you are in good hands.

Tarn:
          Welcome to
DOS For Dummies Part -2

HELP, DIR, D:, and CD
        (in that order)

      Okay, let’s jump right in at the deep end here. Nope! Wait! Sorry, that comes later on. Let’s just get our toes wet for now.
      While using ExifTool at the “Command Line” level, you really only need to know four DOS commands.
        a) Help
        b) Dir
        c) D:
        d) CD

Note: My examples will be on drives T, and U. This is the same as C, or D, or any other drive designation. Substitute your own drive letter for these.
 
      After you open your “cmd window”, or “DOS window”, you will see some verbiage about your operating system and a “Dos prompt”. This (usually) is a line that starts with the letter of the drive you are on and your current “path” followed by the greater than sign “>”.  Almost like below.

Dos_window.jpg[/img]

   This is your “Command prompt”, “Command line prompt”, or “DOS prompt”. This is your computer waiting for you to give it a command.

   Dos is simple and easy to understand. Most of the commands are intuitive, meaning they make sense, they are logical. Also, most of the Dos commands are truncated, or shortened, versions of the function they serve. DIR is short DIRectory, CD is short for Change Directory, and HELP is neither long, nor short for HELP. Hey, I said “most” of the commands…

   Let’s try our first DOS command, ready? Type the following command, and press the “Enter”, or “Return key (I will use Enter from here on out).
HELP
    * You will see a list of all, available DOS commands, with a brief description of what they do.

   

Next, type:
Help
    * You will see the same list as above.
Now, type:
help
    * Again, with the same list.
    * What is my point?
        o Dos commands are not case sensitive.

      The “HELP” command is very important for those just starting out with Dos. It shows you what the commands are, what they do and, most importantly, how to type them. It is also helpful to those who want to use more advance commands, as it shows you what is available, and how to use it. And let us not forget those who need just a little memory jog to get them going.
     
       The next step is to get more detailed information about a particular command. That is done by typing the particular command, a space, a forward slash and question mark. Let’s give it a try, type:
DIR /?
    * Now we’re getting somewhere.
        o Lists the syntax.
        o Lists the options.

      The point is that any Dos command, followed by “/?” will get you help on that command. This is most useful to discover what options are available for any given command (as you will see in a moment).
      Okay, you know how to get general help. And you know how to get help for specific commands. Let’s move on to making some use out of the DIR command.

   Type:
DIR
    * Displays an unsorted list of all files and subdirectories (folders) in the current directory.
        o This is a “non destructive” command.
            * It does not alter, delete, or move any files or directories.
        o It displays only what is in the current directory, nothing else.
        o The list is unsorted.
        o Hidden files are not displayed.
            * Such as “Thumbs.db”
DIR /?
    * Displays the help, and options available for the DIR command.
        o Concise and to the point.
        o We just covered this, if you forgot it already, you’re in big trouble.
DIR /s
    * Displays an unsorted list of all files and subdirectories in the current directory, and all subdirectories below it.
        o /s   Tells dos to search all subdirectories.
            * The list is unsorted.   
            * Unless the files were copied into their current location, in order.
            * Hidden files are not displayed.
            * Screen output is grouped by directory and path.

   

DIR /s/o/p
    * Lists all files and subdirectories, in alphabetical order, and pauses scrolling when your Dos window fills up.
        o /s   Tells dos to search all subdirectories.
        o /o   Tells dos to Order the files alphabetically.
            * Files are listed in alphabetical order.
            * Subdirectories in the current directory are listed at the top of the list.
            * Subdirectories are listed next, in alphabetical order.
        o /p   Tells dos to Pause the output when the Dos window fills up.
            *  Press any key to continue.
            * Press Ctrl-C to abort.
            * “Control” key and the “C” key at the same time.

      Pretty neat so far, huh? It’s not??? Oh well. As you can see the commands are simple and intuitive. DIRectory /Subdirectories /Order files alphabetically /Pause the output.
   In the next step we begin to see some of the power of Dos. Just like Windows Explorer can “Search” for files, and so can Dos. Dos uses wildcards like Windows does. (Where do you think Windows learned it from?) Let’s take a look at a few of the basic ways to narrow down the number of files that the DIR command will search for specific files.

Remember: Dos searches from the current directory down, unless specifically told otherwise. This will be discussed in a little bit.

DIR *.*
    * Does the exact same thing as “DIR”.
        o Using wild cards, it looks for any file name with any extension.
        o From the current directory, down.
        o Powerful, yes?
DIR *.JPG   
    * Looks for any file name that ends with “JPG”.
        o In the current directory only.
            * /s to search subdirectories.
        o Case does not matter. Will return JPG, jpg, JpG, etc.
        o This will, by the way, list any file that ends with “JPG_original” too.
        o However this will not list the four character extension of “JPEG”.
DIR *.NEF
    * Is the same as “*.JPG” except it lists only files that end with “NEF”
        o Case still does not matter.
        o Will list the files ending with “NEF_original” too.
DIR U:\*.JPG
    * Searches the root directory of drive U for any jpg.
        o U:   The letter of the drive to search.
        o \      Backslash, not needed, but it is good form, and becomes a habit.
        o *.jpg   The file specification.
        o /s to search the entire drive, from the root down.
            * 18,000+ files on the drive… Are you POSITIVE you want to do this?

      There, that wasn’t so hard now, was it? Go ahead and play with it. The dir command is harmless and will not alter, or destroy any files. Combine the different wild cards with the different switches “/s, /o, etc.” and see what you get. Oh! Try this one: “Dir /AD”, it’s a hoot.

Tip: DIR > Dir.txt
    * Will send all screen output to a file called “Dir.txt” in the current directory.
        o Your screen will show no activity until the command is completed.
        o Dir.txt will be in the directory you are in.
            * Any text editor can read this file.
            * This file can be “Type”d to the screen.
    * Type Dir.txt <enter>
        o >    Will create the file if it does not exist, and overwrite it if it does exist.
        o >>  Will create the file if it does not exist, and append it if it does exist.
        o Don’t use the /p switch with these two (you can’t see the screen when it pauses).
            * More on the Dos redirect later (maybe).


      Now let’s talk about something very simple, but very valuable to know. How to change drives. There is, really, nothing to it. Type:
U:
    * Changes you to the drive specified by the letter.
        o A single letter.
        o Upper or lower case, don’t matter.
        o Followed by a colon “:”
        o Press the enter key.
        o That’s it! Nothing more.

      I really don’t look at this as a command, although it is, because it is so simple. Most of us operate on more than one drive. Files we work on are on one drive, while the originals, backups, copies, etc. are on another. So getting from one drive to another is necessary in cases like that. And Dos makes this so simple to do. Drive letter, colon, enter. Poof! You’re there!


Skip this part if you understand the DOS “path”. Go down to CD Test for the next part.
      Before jumping into the next command, we need to cover some boring, “dry” stuff. But if you don’t understand the Dos “path”, you will have trouble with the next command, as it deals with changing this “path”, or which directory you are in.

      In Windows explorer, your path is represented by a “Tree”. Starting with the Root directory at the top. Below that, and indented, are any folders (directories) in the root directory. Click the plus sign “+” next to a folder, and it will open up and show the folders under it. This is the “path”. And one it goes until you get to the last folder.

   

      In DOS, you do not have the graphic display like you do in Windows. The path must be stated in, what I call, a “linear” way; as a string. The path for the image above would be: U:\Test\Temp\Working
      It is quite easy, really. It just sounds scary. I may cover this in more detail later. It depends on how in depth people want to get with the path. And, if you have questions, feel free to ask me. I’ll either answer your question, or we’ll find out.

   

Useless information: If it had been Bill Clinton that had developed Microsoft, instead of Bill Gates, we would all be working with “Winders” instead of “Windows”.

      Okay now, the next command you should become familiar with is the “CD” (Change Directory) command. This is the same thing as double clicking on a folder in Windows Explorer.  It is called change directory because it came about before directories were called “folders”. So the command is CD, not CF.
      Unlike the commands Dir and U:, CD by itself does nothing very efficiently. You need to add something after it. Specifically, the directory, (path) you want to change to.
      This command can become confusing for the beginner. Mostly because it is likened to a tree, that is turned upside down. The root(s) are at the top, and the branches are on the bottom. (Leave it up to someone from Microsoft to come up with that analogy)
       But fear not. As long as your directory structure (folder structure, tree) is simple, the Dos path will be simple as well. By simple I mean one level below the root directory. As you work with the DOS path you find that it is quite easy to navigate through several levels deep, and with several subdirectories in other subdirectories. Scared yet?
      Think of it as a path that you would walk on, say, in the woods. The path splits into one, or more other paths. You can only go down one. As you continue, the path may split again. Still you may go down only one path. While you might be able to walk from one path to the other, without having to back track, in the woods. You can’t do that here. You must “back track” to where you can go back down the other path to get to where you want to go. And that is the key point on the DOS path.
      In the example shown for the Windows files, you can see that “Edited” and “Working” are subdirectories of “Temp”. They are “side by side”, so to speak. But you cannot move directly from one to the other. You cannot move laterally between directories in Dos. In other words, you have to move “up” from Working into Temp, then back “down” into Edited. More on this later.

   

   At this point, you may want to create a directory called “Test” on your favorite drive. This will come in handy for playing in and for testing things later on. You do not want to play, or experiment in the same directory that your files are stored in. That’s just begging to get hurt. Copy files into the Test directory where it doesn’t matter if you trash them or not.

   Now it’s time to learn how to move around this pesky little DOS path.
CD test
    * Changes from the current, or root, directory to the “Test” subdirectory below it.
        o CD   is the DOS command.
        o test  is the subdirectory you wish to change to.
        o This can, also, be typed CHDIR, if you want to do it the hard way.
        o This is a non destructive command.
            * Does not change, alter, delete, or rename any files or directories.
        o Note that case does not matter.
CD .. and CD..
    * Moves you up one level, to the “Parent” directory.
        o CD..    the two dots right after the command.
        o CD ..   the two dots right after a space, after the command.
        o Either way works, both move you up (only) one level.
CD\ and CD \
    * Will move you to the root directory of the drive you are on, no matter where you are.
        o Must be a backslash.
            * Yes! Forward slashes do work in path statements.
            * But they do not work behind the CD command.

   


      For simplicity, consistency, clarity and to differentiate DOS path statements from HTML path statements, I recommend the use of the back slash at all times in DOS. It may be a pain in the rump at first; butt in the long run, it does make things easier.


CD \test
    * Will move you from the current directory to the “test” directory below the root directory.
        o The backslash takes you up to the root directory, no matter how deep you are.
        o “test” subdirectory must exist just under the root directory.
        o Operates only on the drive that you are on.
        o Does not create a directory if it does not find the specified directory.
            * You don’t want it creating subdirectories by accident. Trust me!
        o Returns error message if the specified directory is not found.
CD U:\test
    * Changes to the “test” directory below the root directory on drive “U”.
        o Is an “absolute” path statement.
            * Acts only on the drive specified by the drive letter.  “U” in this case.
CD /d U:\test
    * Takes you to U:\test, no matter where you are.
        o /d   switch, moves you to the specified drive and directory, or the path you specify.

Skip this part if you have no trouble with the concept of changing directories on a drive that is different from the one you are on. You are done.

      Here begins a point of minor confusion. Due to the fact that, if you are not on the drive specified in the command (U in this case), you will not see anything happen.
      Also, many people expect this command to take them to the specified directory… it does not (/d does that). All it does is change the specified drive to the specified directory, or path. You will need to use a separate command to change to that drive in order to be in the specified directory. Easy enough to do, just type “U:” (or other drive letter) and press the enter key. Or, you need to use the “/D” switch (type cd /? for info on the /D switch).
      However, if you are on drive U, it will take you to that directory, as long as it exists.
     
      In short, issuing this command, using a drive letter that is the same as the drive you are on, takes you to that directory. Using a drive letter that is different than the drive you are on, sets that drive to the specified directory; and you have to change to that drive with a separate command.


      Well, that’s it for this section. I hope it was not too long winded; just as much as I hope it was long winded enough to help. Or at least get you pointed in the right direction. Show you enough to know how to get help, or maybe just remind you of something you forgot.

      So, created that Test directory on you favorite drive, and play. Take these commands out for a spin and see what they do. This isn’t much, but it will get you to the drive and directory that you want to get go to; and it will let you know what files are there when you arrive. You still have the old, familiar Windows Explorer to copy, move and delete files; and to created or delete directories.

      Help, Dir, U:, and CD are all harmless commands. But still… remember to work with (extra) copies of your files, never on the original files, or the only copies that you have of files.

Navigation

[0] Message Index

[#] Next page

Go to full version