PROBLEMS WITH SAVING PATHFOLDERS

조회 수: 5 (최근 30일)
Galo Oviedo
Galo Oviedo 2024년 1월 8일
답변: Image Analyst 2024년 1월 9일
Hello, currently I'm working with exiftool to change the attributes from some pictures, I run this script in my computer and I don't have any problem with them, however when I install Matlab2021a in my office computer, I run my script and I have and adverstiment about the script doesn't find the specified path. I don't know what it's problem, I give all the permits to all users but neither. Please help to find some answer or solution to my problem.
  댓글 수: 2
Steven Lord
Steven Lord 2024년 1월 8일
Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error. Don't paraphrase, don't summarize, copy and paste.
You may also need to show us a small sample of code with which we can attempt to reproduce the problem.
Galo Oviedo
Galo Oviedo 2024년 1월 8일
편집: Stephen23 2024년 1월 9일
No, the only warning that I recieve is this:
This is my code, I do in a function however I test this in my house computer and the code works well.
function batchAddAndExportCoordinatesWithFile(folderPath, outputFolderPath, coordinatesFilePath)
% Specify the path to the ExifTool executable
exiftoolPath = 'C:\EXIFTOOL\exiftool.exe';
% Read coordinates from the TXT file
coordinatesData = importdata(coordinatesFilePath);
% Get a list of all JPG files in the specified folder
files = dir(fullfile(folderPath, '*.jpg'));
% Check if the number of coordinates matches the number of images
if length(coordinatesData) ~= length(files)
error('Number of coordinates in the file does not match the number of images.');
end
% Iterate through each file and apply the function
for i = 1:length(files)
% Full path to the original image
originalImagePath = fullfile(folderPath, files(i).name);
% Create the output file path based on the original file name
[~, fileName, fileExt] = fileparts(files(i).name);
outputImagePath = fullfile(outputFolderPath, [fileName '**' fileExt]);
% Extract coordinates from the data read from the file
currentCoordinates = coordinatesData(i,:);
latitude = currentCoordinates(1);
longitude = currentCoordinates(2);
% Build the command to add GPS coordinates and export to a new file
command = [exiftoolPath ' -GPSLatitude=' num2str(latitude) ' -GPSLongitude=' num2str(longitude) ' -o ' outputImagePath ' ' originalImagePath];
% Execute the command using the system function
status = system(command);
% Display status for each image
if status == 0
disp(['Coordinates added and image exported successfully: ' files(i).name]);
else
disp(['Error processing ' files(i).name]);
end
end
end
clc;
clear all;
close all;
% BATCH OF PROCESS
folderPath = '\path\folder\test';
coordinatesFilePath = 'coordinates\test\coordinates.txt';
outputFolderPath = '\output\folder\test2';
batchAddAndExportCoordinatesWithFile(folderPath, outputFolderPath, coordinatesFilePath);
All the paths are an example not the originals.

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2024년 1월 8일
I'd say that you don't have the folderpath on your computer
folderPath = '\path\folder\test';
or else the images are not in that particular folder.
  댓글 수: 2
Galo Oviedo
Galo Oviedo 2024년 1월 8일
이동: Image Analyst 2024년 1월 8일
That path it’s only an example not the original path
Image Analyst
Image Analyst 2024년 1월 8일
Well whatever it is, the answer is the same. That folder does not exist or the files are not in it. What does this say
folderPath = '\path\folder\test'; % Replace with actual path
if ~isfolder(folderPath)
errorMessage = sprintf('The folder %s does not exist!', folderPath)
errordlg(errorMessage);
return;
else
message = sprintf('The folder %s does exist!', folderPath)
uiwait(helpdlg(message));
end

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2024년 1월 9일
I noticed that you included the drive letter in one path but not the others. Try putting the drive letter in all paths. What operating system are you using? Does it use drive letters (Windows) or not (Unix, mac)?

카테고리

Help CenterFile Exchange에서 External Language Interfaces에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by