How to copy a video file from an external drive to the current workspace?
1 次查看(过去 30 天)
显示 更早的评论
I am working on a script which will loop through a group of large videos that I have on an external drive. In psuedo codo I want to:
loop for all files
copy video to current workspace (to increase reading speed)
open video visually
mark certian frame and time stamps
close video & delete local copy
end loop
I have most of this working except I cannot get the copyfile function to work for me, here is what I have written -- any help would be great
[file,path] = uigetfile('*.avi');
name = join([path,file]); % This is a char
CurrentDirectory = 'C:\Users\username\Desktop\Currently Working On'; % this is a char
copyfile name CurrentDirectory;
%% -- ERROR MESSAGE -- %%
% Error using copyfile
% No matching files named 'C:\Users\username\Desktop\Currently Working On\name' were
% found.
0 个评论
采纳的回答
Jayant
2023-6-27
What I think is the issue you're experiencing is due to passing the variable "name" as a literal string instead of its value. To fix this, you need to concatenate the value of name with the destination directory. Here's the corrected code:
[file, path] = uigetfile('*.avi');
name = fullfile(path, file); % Create the full file path
CurrentDirectory = 'C:\Users\username\Desktop\Currently Working On';
copyfile(name, CurrentDirectory);
By using the "fullfile" function, you ensure that the file path is constructed correctly, taking into account the operating system's file separator. Then, you pass the "name" variable (which holds the full file path) and the destination directory to the "copyfile" function. You may refer to this fullfile & copyfile documentation.
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing and Computer Vision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!