I want to get the Date Taken
parameter for an image (identified by NAME_OF_AN_IMAGE
variable with PATH_TO_IMAGE_FOLDER
constant) and pass it to the main batch script; within the batch script I must use a Powershell instruction (it is not possible to get the Date Taken
directly by cmd command).
I have to provide a NAME_OF_AN_IMAGE
variable to the Powershell script and at the same time bypass the restricted execution policy.
Briefly, the date taken for the named image should be returned from the Powershell script and set to the Date
variable within the batch file.
I have the following lines of commands within the Powershell 'DateTaken.ps1' script:
[reflection.assembly]::LoadWithPartialName("System.Drawing");
$imagePath = "PATH_TO_IMAGE_FOLDER\NAME_OF_AN_IMAGE.JPG";
$pic=New-Object System.Drawing.Bitmap $imagePath;
$DATE = $pic.GetPropertyItem(36867).value[0..9];
$strYear = [Char]$date[0],[Char]$date[1],[Char]$date[2],[Char]$date[3];
$strMonth = [Char]$date[5],[Char]$date[6];
$strDay = [Char]$date[8],[Char]$date[9];
$DateTaken = $strYear + "." + $strMonth + "." + $strDay;
and within the batch file:
I am not able to run the set of Powershell instructions listed above in order to get to the $DateTaken
variable and assign it to Data variable within the batch script.
If I get the set of the above Powershell instructions to return the value of Data
, I will be able to pass it into the temp.txt file using the grater than sign '> temp.txt' and then read it into the batch file by set /p Data< temp.txt
command.