ExifTool Forum

ExifTool => Newbies => Topic started by: Tarn on February 26, 2013, 12:51:05 AM

Title: DOS command line tips.
Post by: Tarn on February 26, 2013, 12:51:05 AM
Many of the older hackers already know this stuff. This is for those who are learning about DOS commands for the first time. And for those who have forgotten them.

Here are a couple of simple tricks you may find useful at the DOS prompt (in the CMD window. They involve the use of the <F3> key; the <U> up arrow key; and the <D> down arrow key.

Using the up arrow key will echo your last command as if you had re-typed it. Pressing <U> again will echo the command previous to that. You can scroll backwards through the last 20 or so commands that you have typed. Useful when you want to re-enter a long command that has lots of Perl notation in it.

Using the down arrow key will take you forward through the list; from oldest to most recently typed.

Next is the <F3> key. It echoes your last command only, but with a twist. It echos it from your cursor position. Here is an example.

dir *.*_original /s <Enter>

This will list any filename, with any extension plus "_original" added to the extension, in your working directory and all sub-directories. Now type:

del <F3> (don't hit enter yet)

You will see that pressing the <F3> key has added "*.*_original" after your "del". Pressing <Enter> will issue the delete command as if you had typed it; and will delete all the files listed with the "dir..." command.

If you were to type in:

copy (space) <F3>

You would end up with:

copy .*_original

That is because <F3> echoes the last command from your cursor position. Typing "copy " puts you two places past "dir" or "del" and into the command argument. You can avoid this problem by adding extra spaces after a short command like "dir" or "del".

Saving "dir *.*_original /s" to something like "orig.bat" is an easy way to see, or find any of the backup files created by ExifTool. And saving "del *.*_original /s" as something like "origd.bat" is a quick easy way to remove those backup files, when you want to do more work on the same files. (I always work on copies anyway.)

One last trick. Ever spend a lot of time trying to, correctly, type in a command? Try after try... frustration building... then... finally you get it right. Now the trick is trying to re-type that, correctly, into a batch file for later use. Here's the trick. First you get the following command to work:

"-filename<${datetimeoriginal}-${filenumber}.%e" -d %y%m%d *.* -P –progress

Now, hit <F3>, or your up arrow key <U>. You will see the same command echoed at the DOS prompt. At the tail end, add a space and type:

> datename.bat (include the ">" right arrow)

Use your left arrow key <L> to scroll to the very beginning of that line, where you can go no further. Now type:

echo (space)

Your command line should look like this:

echo ExifTool "-filename<${datetimeoriginal}-${filenumber}.%e" -d %y%m%d *.* -P -progress > datename.bat

Look for "datename.bat" in the directory (folder) you were working in. Edit it to add one more "%" to your variables. Change .%e to read .%%e; and change %y%m%d to read %%y%%m%%d. (you need the second "%" because of the batch file. Save that change, and, in the future, just type

datename <Enter>

And you have saved yourself some typing.  I would recommend that you move the file into your C:\windows directory. That is in your path and keeps the file from getting deleted by an errant "del *.*" command.

Hope this helps the newer people.

Dislcaimer: This is for Windows. I know bupkiss about MAC.

Title: Overuse of wildcards
Post by: Phil Harvey on February 26, 2013, 07:47:12 AM
Here is an exiftool-specific command line tip that really needs to be mentioned somewhere, so here is as good a place as any...

It is often preferable to specify a directory name (ie ".") instead of using wildcards (ie "*.*") for a number of reasons:


- Phil