-
Notifications
You must be signed in to change notification settings - Fork 2
/
dropsync.m
54 lines (42 loc) · 1.57 KB
/
dropsync.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
% function [ filescopied ] = dropsync( dropboxpath )
%% dropsync - Dropbox Synchronizer
% Syncronizes current directory with dropbox directory of the
% same name
%
% Daniel Shuldman <[email protected]>
% Version 0.1
% Author's Default Dropbox Location
defaultdatadir = 'D:\shuldman\data\';
defaultdropboxpath = 'D:\shuldman\dropbox\DH\';
% if nargin < 1
dropboxpath = defaultdropboxpath;
% end
fullpath = pwd;
[upperpath, currentdir, ~] = fileparts(fullpath);
filesortcurrent = struct2cell(dir(['*.*']))';
filesortcurrent(1:2,:)=[];
[numfilescd, ~] = size(filesortcurrent);
for L = 1:numfilescd
filesortcurrentcomp(L) = cellstr([filesortcurrent{L,1:2},(num2str(cell2mat(filesortcurrent(L,3:5))))]);
end
dropboxsubpath = upperpath(numel(defaultdatadir):end);
dirnameloc = regexp(dropboxsubpath,'[\\/]');
dropboxsubpath = dropboxsubpath(dirnameloc(1)+1:dirnameloc(2));
dropboxpath = [dropboxpath,'\',dropboxsubpath,'\'];
dropboxpath = [dropboxpath,currentdir,'\'];
dropboxpath = strrep(dropboxpath,'\\','\');
dropboxpath = strrep(dropboxpath,'\\','\');
if ~exist(dropboxpath,'dir')
mkdir(dropboxpath);
end
filesortdropbox = struct2cell(dir([dropboxpath,'*.*']))';
filesortdropbox(1:2,:)=[];
filesortdropbox(:,4) = num2cell(double(cell2mat(filesortdropbox(:,4))));
[numfilesdb, ~] = size(filesortdropbox);
for L = 1:numfilesdb
filesortdropboxcomp(L) = cellstr([filesortdropbox{L,1:2},(num2str(cell2mat(filesortdropbox(L,3:5))))]);
end
for
strcmp([filesortdropboxcomp(L)],[filesortcurrent])
% copyfile('*.*',dropboxpath)
% end