フィルターのクリア

How do i move images based on their names in table to certain directory?

2 ビュー (過去 30 日間)
ahmed obaid
ahmed obaid 2017 年 4 月 15 日
コメント済み: Image Analyst 2017 年 4 月 16 日
Dear experiences ..
i have a lot of images that exist in (D:\test) directory, where images names are store in column table called (names).. look like the following :
2403695909.jpg
4605630935.jpg
4605630989.jpg etc..
i need to move images where their names in this table to another directory (D:\master),
thanks for any suggestion..

採用された回答

Image Analyst
Image Analyst 2017 年 4 月 15 日
編集済み: Image Analyst 2017 年 4 月 15 日
Go down the table and use exists() to determine if the name in the table is in the source folder, and if it is, move to the destination folder with movefile(). Something like (untested)
sourceFolder = 'C:/Mordor'; % Wherever....
destinationFolder = 'D:/Valhalla';
% Make destination folder if it doesn't exist
if ~exist(destinationFolder, 'dir')
mkdir(destinationFolder);
end
for row = 1 : size(yourTable, 1)
thisName = table{row, 1}; % Extract name from table
% See if it exists
fullSourceName = fullfile(sourceFolder, thisName);
if exist(fullSourceName, 'file')
fullDestinationName = fullfile(destinationFolder, thisName);
movefile(fullSourceName, fullDestinationName);
end
end
  2 件のコメント
ahmed obaid
ahmed obaid 2017 年 4 月 16 日
Undefined function 'exist' for input arguments of type 'cell'.
Image Analyst
Image Analyst 2017 年 4 月 16 日
ahmed, you forgot to include either your entire error message or your data file, so all I can do is guess. If this was the exist that didn't work
fullSourceName = fullfile(sourceFolder, thisName);
Then cast thisName to char:
fullSourceName = fullfile(sourceFolder, char(thisName));

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by