Main Menu

Windows Power Shell

Started by redders47, December 19, 2017, 07:26:24 PM

Previous topic - Next topic

redders47

I know zip about programming, but by following examples from various documents I can use Windows Command Prompt to extract csv files from folders of photos and then use those csv files to load back new information (usually captions and dates) to photos in the folders.

Using this method I have placed descriptions in the metadata of thousands of my photos.  Despite my lack of understanding I have used exiftool to ensure my photo's subjects and dates are easily accessible through time.

I typically copy the photo folder to the desktop and use these commands:

exiftool -all -csv desktop/photofolder > desktop/fotofolder.csv  (Giving me all the metadata to which I add the necessary tags - I know this could be more tag specific but the volume of data extracted doesn't worry me)
exiftool -csv=desktop/fotofolder.csv desktop/photofolder           (Copying the revised metadata back into the photos)

My concern is that this is fine while the Command Prompt is available through Windows, but if I have only Windows Power Shell to work with (and I think the Command Prompt may be on the way out) these commands do not work the same.  Using my first command with Power Shell I get a csv file, but all of the metadata appears in one column separated only by commas, which makes it incredibly difficult if not impossible to add tags and descriptions etc in an easy way.

Is there some amendment to the commands above that allow me to use Power Shell and get the same results as with Command Prompt?

Finally, exiftool has allowed me to ditch the very unsatisfactory method of keeping photo descriptions in separate spreadsheets, and it has allowed me to date an important historical family collection.

What a brilliant tool.







StarGeek

What program are you using to load the CSV files?   I did a quick test with LibreOffice and had no problem.  But I faintly remember someone having a problem with import while using Excel which worked fine in Libre or Open Office.

So it might be partially an import problem.  It turns out that Powershell will automatically try to translate output text into UTF.  LibreOffice recognized that there was a difference when I ran the same command on CMD and Powershell and changed the Import Character Set dropdown to match.

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

redders47

Thanks for the quick response.  I am using Excel.

redders47

Thanks again for your help.  It looks like Excel is causing the problem as you indicated.  I downloaded a simple free csv viewer from the MS Store and it loads the tags into columns.  I will access a btter option than Excel to do this work unless there is an easy fix to the Excel option.

StarGeek

You could try this Stackoverflow answer.  There's the extra step of opening excel first and then importing rather than just clicking on the file.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

redders47

Thank you.  That works for me.  I appreciate all your help. 

redders47

Sorry to say this didn't work for me after all.  I can easily read the downloaded file from the photos in columns with different editors, but that same file will not load back to allow me to amend the photo metadata.

So - I am continuing to fumble around, but I suspect the real answer resides in amended coding to get the file from the photos in the correct format, and then load it back in the same format.  As I said in an earlier post that is beyond my pay grade, as they say in the movies.




Phil Harvey

When you say "will not load back", do you mean using exiftool to read the CSV and write back to the images?  If so, what was the command you used, and what messages did you get?  Also, it would help if you posted a sample CSV file that doesn't work.

- 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 ($).

StarGeek

Are you making sure that Excel is saving the file back as a CSV?
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

redders47

First I went back and just used the Command Prompt on two files in a folder.  I was able to change and save the metadata back to these files(photos) using both Excel (2010 version) and LibreOffice 5.4.  The extracted csv file when opened with Excel appears in columns. I imported the file into LibreOffice using UTF -16 and commas as separators to make it appear in columns.

I then used Power Shell and the csv extracted by the command exiftool -all -csv desktop/photos > desktop/extract.csv is attached.  If I open it with Excel all the metadata appears in one column only - totally different from the result with Command Prompt.
If I try to load this file back immediately, without any amendment, using exiftool -csv=desktop/extract.csv desktop/photos then I get No Source File errors as shown in the capture of Power Shell dialogue.

If I amend the file I get the same errors, whether I amend in Excel or LibraOffice.

Hope this is clear and, once again, I really appreciate the help




StarGeek

From the image:
QuoteError opening CSV file 'desktop/extract'

It looks like more Powershell hijinks.  Powershell is only passing desktop/extract as the filename.  Try putting quotes around that part "-csv=desktop/extract.csv" (try single quotes also).

Nope, just tested that.  It will find the csv file, but then this error pops up:
PS D:\> exiftool -P -overwrite_original '-csv=temp.csv' y:\!temp\Test3.jpg
Invalid tag name ' ■S o u r c e F i l e ' in CSV file
No SourceFile 'y:/!temp/Test3.jpg' in imported CSV database
(full path: 'y:/!temp/test3.jpg')


Now you know why I dislike powershell.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

redders47

As someone who can only follow a recipe then much of this is beyond me.  But I do know Command Prompt does the job for me and Power Shell does not.  As I indicated earlier, if Command Prompt disappears in later Windows versions then I am up the creek without a paddle. 

StarGeek

I wouldn't worry about it.  It's unlikely that CMD is going away.  It is being replaced as the default shell, but that doesn't disable it.  Even so, if you're running Windows 10, you can always switch to Bash.  The syntax is a bit different but most exiftool commands should run the same except that you may have to swap the double/single quotes.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).