How to copy a video file from an external drive to the current workspace?

2 次查看(过去 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.

采纳的回答

Jayant
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by