News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Getting started: Command-line ExifTool in Windows

Started by Phil Harvey, March 19, 2013, 09:23:17 AM

Previous topic - Next topic

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

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.

Tarn

            Welcome to
DOS For Dummies Part - 3

                   DEL
Not to be feared, just respected

   I was going to cover this command later, but decided to cover it now before anyone discovers it on their own (read: By accident). The DELete command is, by far one of the most powerful and useful commands in DOS.
   Before using this command, you need know only four things:
      a) DEL *.jpg   is a file killer!
      b) DEL *.* /q   is a directory killer!
      c) DEL *.* /s/q   is a drive killer!
      d) There is no such thing as a "Recycle bin" in DOS.

   I tell everyone that DOS is nothing to be afraid of, and I encourage people to "play" with it to see what it can do. The DELETE command is however, one that I urge caution with. While one of the most useful commands, it has the power to be just as destructive as it is useful.
    To put things into perspective, there is only one other DOS command that causes more fear, heartache, and misery to people than the DEL command. Please keep this in mind as you reach for the <Enter> key.
    For files deleted from the command prompt, you will need a good file recovery program (already) installed on your system, as installing one after the fact can overwrite deleted files.
     
    Now that I've terrified you, let's get used to what this useful and powerful little command does.
   
    One important change in this section: unlike previous examples where only the command was listed, with no indication of pressing enter or return after it... in this section DO NOT press the enter key or the return key until you see this: <Enter>. If you don't see it, don't do it.
   Now type:
DEL /?<Enter>
   * It's safe, don't worry.
   * Brings up the help on the DEL command.

    As you can see, the DEL command uses syntax and switches very similar to the DIR command. This is a good thing, and it is a bad thing. Mostly because DEL and DIR are the same length and only two characters apart.
   For example:
DIR a.jpg /s
   * Finds all instances of a.jpg in all subdirectories.
DEL<F3> (DO NOT press enter)
   * DELTES all instances of a.jpg in all subdirectories.
      o Fortunately, it will ask you first.
DEL<F3>/q (DO NOT press enter)
   * DELETES all instances of a.jpg in all subdirectories, without asking.

    Remember all that babbling I did about the F3 key? This is where it can be a big help. By looking for, and displaying specific files, then deleting those same files. I have created a batch file that looks for orphaned, or forgotten ".jpg_original", ".nef_original", etc. files. It picks only those files and displays them. A second batch file deletes those same files, using the same conditions. Very helpful when you forget and move a finished folder to the archives, then discover you left the "original" files in there.
    The DEL command will select files the same way that the DIR command does. You can select based on the extension; you can select based on a few characters of the file name, or any other selection process that the DIR command uses. The only difference is that the DIR command will show them to you; while the DEL command never lets you see them again.
    Another useful feature of the DEL command is it can remove files based on attributes. Let's pick on "Thumbs.db". If you don't have it, viewing the directory with explorer, in thumbnail view, will create it.
    Make a directory called "Test". Next move four files into it. Name them: a.jpg, b.jpg, c.jpg and image.jpg. Now, open your Windows explorer, switch to thumbnail view if you are not in it, and visit the root directory where Test is located, then go into Test itself. This should create Thumbs.db. Let's check to see if it's there, type:
DIR *.* /ah /s<Enter>
   * Will list all hidden files in the current directory, and all subdirectories.
      o /ah   Is the switch to list any file with the "Hidden" attribute set.
   * If Thumbs.db is there, it will show on the list.
   * Any other "Hidden" file will list as well. Watch for this.
      o /s   Searches all subdirectories.



NOTE: SKIP this next step if you have any other hidden files show up along with Thumbs.db. They will be deleted along with Thumbs.db in this next step. If Thumbs.db is the only file that displayed with the "DIR *.* /ah /s" command then join in and type:
DEL *.* /ah /s   or   DEL<F3><Enter>
   * Deletes all files with the hidden attribute set.
      o *.*   Acts on ANY file.
      o /ah   Acts on ANY file with the "Hidden" attribute set.
   * Those that are not "Hidden" will be exluded.
      o /s   Acts on the current directory, and all subdirectories below it.
      o This will prompt you "Are you sure? (Y/N)" before deleting any files.
         * Y   deletes the files.
         * N   aborts the command.
DEL *.* /ah /s /q (DO NOT press Enter
   * Deletes all files with the hidden attribute set, in all subdirectories.
      o For you that work on "C" drive, this can be a very dangerous thing to do.
      o /ah   Is the switch to act on any file with the hidden attribute set.
      o /s   Acts on all subdirectories.
      o /q   Does not ask for conformation.
    The "/q" switch (quiet) can be a time saver. Just remember that it removes your last safeguard when you use it.

    If you ever try to remove a directory with the RD command, and you get told that the directory is not empty yet there are no files, or subdirectories in it... "Thumbs.db" is the problem 99% of the time. It will not show up with the normal "Dir" command, yet it is there, lurking. Remember how I said that DOS is not out to get you? Well Thumbs.db IS out to get you.

    Okay, remember those files I told you to create in the Test directory? Well we get to kill them now. And we are not going to kill them just once... Oh No! We're gonna kill them a few times. So now would be a good time to back them up somewhere that you can easily copy them from.
    With a.jpg, b.jpg, c.jpg and image.jpg in your Test directory, change to that directory, and type:
Dir<Enter>
   * Displays all files and subdirectories in the current directory.
      o You should see all files listed.
      o But not Thumbs.db (it's hidden).
Del b.jpg<Enter>
   * Deletes only the file specified.
      o b.jpg is gone.
      o No prompt for a single file delete.
Dir<Enter>
   * Display the files.
      o Notice that b.jpg does not show up.



    Your display should look similar to the image above. Keep in mind that your file sizes will, most likely, be different than mine.
As you can see, only b.jpg was deleted. Had there been a file named bb.jpg, it would not have been deleted.
    For the next step, create three more files: aa.jpg, bbb.jpg cccc.jpg. An easy way to do this is from the command line:
Copy a.jpg aa.jpg<Enter>
Copy a.jpg bbb.jpg<Enter>
Copy a.jpg CCCC.jpg<Enter>
   * Makes a copy of the file a.jpg and names it as: aa.jpg; bbb.jpg; and cccc.jpg.
       Now, type:
Del ?.jpg<Enter>
   * Deletes any file with one (1) character in the file name, with the extension of jpg.
            o a.jpg, b.jpg and c.jpg are gone.
            o All other files are still there.



    Let's try something fancy. Let's delete some files that have different file names, and different extensions, all at the same time.

    If you want to follow along, move a.jpg, b.jpg, and c.jpg back into the Test directory, and run any Exiftool command without the "-overwrite_original" option, in order to create the "original" files. Or you can just sit back and relax for this.
    Take a look at the picture below. You will see our friends a.jpg, b.jpg, c.jpg and image.jpg. We also have aa.jpg and bbb.jpg back for another appearance. And a new guy, b.NEF. And there are a lot of "_original" files there too.
    Let's get rid of those _original files. Type:
Del *.*_*<Enter>
   * Deletes all files with an underscore in the extension.
      o The first asterisk takes care of the file name, it can be anything at all.
      o The dot ends the file name and begins the extension.
      o The second asterisk will take care of any extension before the underscore.
   * No matter how long, or short.
      o The underscore is what does the trick.
         * It is the only character that is specified.
         * Not a wild card.
      o The third asterisk looks for anything after the underscore.
NOTE:There was no prompt to confirm this delete command. That means that you can take out a number of files without realizing it, should you make a mistake in typing.  For example, similar, yet different "*-*.*" (reversed and with a dash) could have disastrous results for a lot of people. as in files that are named: "990615-1955.JPG"



    Despite having three wildcards in the name, this is a very specific command. It deleted files with different extensions, JPG and NEF files. It deleted files with different file names, and different length file names. Yet it did it with pin point accuracy. Deleting only the files we wanted. Contrary to what you might think, this did not delete the files ending with "_original". The "original" was not part of the selection. This deleted all files that had an underscore in the extension. It could have been "image.perl_rocks" and it would still have been gone... because of the underscore.
    One word of caution here. "*.*_*" will get rid of the "original" files and leave the JPG files. "*.jpg" will get rid of the JPG files, and the "original" files too. Reason being the extension starts with "JPG". Let me show you:
Del *.jpg<Enter>
   * Deletes any file with an extension that begins with JPG.
      o Will take JPG_original files too.



    As you can see, all we are left with is the "NEF" files.
     
    The Del command is very, very powerful. Del can delete every single *.ext_original" file from every single subdirectory on your entire drive; with pin point accuracy that leaves all other files undisturbed. Olympus owners my want to use "Del *.thm /s /q" to remove the thumbnail images that some of the Olympus cameras produce.
    Del has the power and versatility to delete just one file among thousands, or it can delete thousands at once. And that makes this command stand above all others.
    But with that power to do so much good, comes the power to do just as much evil as well. The command "Del *.* /s /q" will deleted every file, in every subdirectory, from the current directory on down. If you are deleting files from a working directory, that you no longer need, this is a good thing. If you do this in the root directory of your archive drive... your tears will fall like rain. So be aware of where you are when you issue a command like that.
    With a little practice, and a good understanding of how to select files based on file names and using wildcards, you will soon be removing all the junk files from your entire hard drive with one command. Or you can get rid of one, single file, that is buried fifteen levels down.
     
    This section was not written to scare you. Quite the contrary. It was written to encourage you to use this useful command with confidence. It was written in the hopes of getting you to respect, not fear, the command. It was written to help you realize that it is a useful, but powerful command.
     
    Create a "Test" directory. Load it with all kinds of files. Play with it, learn what it can do, and what it can't do. If you ever are hesitant about using the Del command in your working directory, copy the files to Test and try it there. Get to the point where you no longer fear it. But always respect it.
     
    One last, final word of caution, regarding the "Del *.* /s /q" command. This is aimed toward those who work on your "C", or system drive (laptop users mostly). Do Not do this in the root directory of your "C" (or system) drive. You will not like the results.
    That's not a threat... it's a promise!

dhapp

Hi,

This is my very first attempt to get ExifTool to work in Windows 7.

I entered the following at the command line
exiftool C:\Users\Doug\Desktop\ELEPHANTS\MisnamedStuff\IMG_0146.JPG
and received the following result:
warning.pm did not return a true value at C:/Perl/lib/Carp/Heavy.pm line 234.
BEGIN failed--compilation aborted at C:/Perl/lib/Carp/Heavy.pm line 234.
Compilation failed in require at -e line 308.


I'm not sure where to start figuring out this problem.

Doug

Phil Harvey

Hi Doug,

It looks like you already have Perl installed, and that there is something wrong with this installation.

If you are use the Windows .exe version of ExifTool, then you don't need Perl.  In this case, try renaming (or removing) your C:\Perl directory.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

trudge

Just reading the post by Phil about CLI for DOS users. Would there be a need of a similar document for us Mac users? I typically have a shell window open all the time and spend half my time in it. I'd certainly be interested in collaborating with someone on this.

Anyone?

Phil Harvey

The steps to run ExifTool on a Mac are identical, except that you launch the Terminal app from /Applications/Utilities instead of cmd.exe.  The rest of the steps are the same.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

krzysiu

1. If you want write batch scripts with exiftool you might want to look into http://ss64.com/nt/ - it's one of the best manuals
2. Instead Start>Run (which is sometimes hidden) you could use shortcut Win+R
3. If you want to change PATH or any environment variable (e.g. to be able to run exiftool without preprending it with path), you need to restart console to get it into action.
4. You may want to create some directory for different tools and add it to PATH variable. I have c:\sharedlib with tools like exiftool, ffmpeg, curl etc.
5. If you use exiftool for the same operations you may want to create batch file with the command. To use command, you just need to drag folder or file and drop onto script. In the command itself you need to change file/directory parameter to %1. Don't add quotes, they will be added automatically, if needed (i.e. when there are spaces in path). If you don't want autoquoting, use %~1.
6. If you are failing with your scripts, don't worry! Batch files are difficult. Keep trying, keep asking and don't expect much from batch files.
7. If you would want to create some menu in batch file (e.g. "do you want to delete original files [yes/no]?") the proper command would be http://ss64.com/nt/choice.html
7a. If you find parsing output of CHOICE difficult or you want to save your last choice to reuse it on the next run, you may want to use this piece of code: https://gist.github.com/Krzysiu/d3dbdb3b6759baa21815a57c8e0d89cd
8. If something don't work, at first check if generated command line is correct. Put echo before line and pause in the new line, after "echoed" one. Review it manually. Maybe problem lies there.
9. If you want to delete some file, but you prefer to put in into recycle bin, the easiest would be to download third party command line tool. You will find a lot of them with minor differences by asking google for "recycle.exe" or "recycler.exe". I'm PC technican yet my experience doesn't mean I don't make mistakes, that's why I'm using it. I recommend the same!
10. For problems with command line or batch files, I recommend StackOverflow or (eventually) Superuser (two websites, yet the same network of websites). It's a question/answer website, but answer needs to be ontopic, so you won't find answers like "i have the same problem, help". By my experience it's the best and the knowledge of users make answers not only "correct" but often the best ways to achieve something.
"We would use teleporters and live on another planets, if only ExifTool would be present when I was researching cosmos and physics"
Albert Einstein

Paul Barrett

In Windows 10 I can get to the command prompt by right clicking the Start button and selecting it from the pop up menu.  I always choose the 'Command Prompt (Admin)' option just in case there are any file access issues.

krzysiu

Sorry, but it's against most basic rule of security: never use elevated accounts, unless in great need. I find it very unwise to teach newbies (and it's getting started topic) such crime.

If Exiftool can't access something because account privileges, then you simply messed up permissions or you put your files in the place where it shouldn't be. Either way there's no way that Exiftool would need elevated account unless something's very wrong with instance of operating system.
"We would use teleporters and live on another planets, if only ExifTool would be present when I was researching cosmos and physics"
Albert Einstein

westrock2000

#13
I had a heck of time getting Japanese characters (UTF-8) to work on the command line of Windows. I tried many tricks, eventually I accepted that your aren't going to able to pass Japanese characters to Exiftool on the command line.

You either need to use the native Perl implementation, or use the "csv" switch for Exiftool and tell it to interpret it as UTF-8.

If you are wanting to get all files in a subdirectory with a given extension and pass them through Exiftool, you need to enable UTF-8 mode in cmd.exe. Output the dir command to a textfile with UTF-8 enabled., and then tell Exiftool to read that file as UTF-8

# Run this before you start your script or save files. Switches to UTF-8 mode.
chcp 65001

# This will search recursive for given extensions and output all to the songlist.txt file, it will be encoded in UTF-8.
# chdir switches the cmd to the base folder and then runs dir in recursive mode
chdir /d E:\Music && dir /s /b *.mp3 *.flac *.m4a  > e:\exiftool\songlist.txt

# Now run exiftool and it will read the contents of the file correctly.
exiftool -@ songlist.txt -charset filename=utf8

With chcp 65001 enabled, cmd.exe will be able to read UTF-8, but it still won't display it correctly. That's why you can't just pass it to exiftool through the command line itself, because the characters will still get garbled during the transition and exiftool will choke. Even though cmd.exe knows what the characters are. It can't render them correctly.

Don't bother with 8.3 dos names. It it possible to generate a 8.3 format name from UTF-8 files, but getting it displayed in a useable format that you can parse for scripting is about impossible.

Exiftool is incredibly fast when running from the text file, compared to individual files....but you loose some freedom in skipping files going this way. Unless you output 1 path to the file at a time and invoke for each file. Look here if considering this route:
https://exiftool.org/index.html#performance

I was originally going this route for portability, but honestly after dealing with UTF-8 in cmd.exe, I'm looking at throwing in the towel and going full Perl. This is how I do it on Mac since Perl is built-in and Mac doesn't have issues with UTF-8. So this problem never showed up before. And don't bother with PowerShell, it's the same problem....just more convoluted. Now I know why I never got in to scripting on a Windows platform.

Or you can do this:
exiftool.exe -r -s -ext mp3 -ext flac -ext m4a e:\temp

This will work with or without chcp 65001, though the text will be garbled in either case that is printed to the screen. So you might want to export it to a file and process the file. The UTF-8 characters will be properly printed to file without chcp 65001 being turned on.

koka

Install https://chocolatey.org/install
Then:
choco install exiftool