Page 1 of 1

Sync directory script

Posted: 17 Dec 2019 23:18
by OsunSeyi
Hi,
unfortunately I didn't found an app to mirror several directories from the internal storage to the sdcard (what is no problem for several clouds like 'foldersync' or 'dropsync'). Best choyce seems to be 'Auto Transfer'. This app copies all changed or new files, but it won't delete files from the target which are deleted on the source-directory.

Of cause, I know it's possible to create something nice with automagic, perhaps there is an easy solution?

At the moment I try to compare directories:

Code: Select all

{source_list} contains:

[.ttxfolder, Apk, Applications, Automagic, Kalender, Kontakte, READ-Dropsync.txt, READ-Restore.txt, Timesheet]

{target_list} contains:

[.ttxfolder, Apk, Applications, Automagic, Kalender, Kontakte, READ-Backups.txt, READ-Dropsync.txt, Test, Timesheet]

Now I would like to extract the Items in the target, which are not in the source for deleting, in this excemple 'Test':

items_to_delete = removeAllElementValues(target_list,source_list);

{items_to_delete} contains:

[.ttxfolder, Apk, Applications, Automagic, Kalender, Kontakte, READ-Backups.txt, READ-Dropsync.txt, Test, Timesheet]

...but it should contain only 'Test' !?
So what I'm doing wrong here?
Btw.. it's so absolute hard typing code on a handset...

Re: Sync directory script

Posted: 18 Dec 2019 11:58
by jassing
Always good to post actual code/flow.

Code: Select all

source_list = newList('.ttxfolder','Apk','Applications','Automagic','Kalender','Kontakte','READ-Dropsync.txt','READ-Restore.txt','Timesheet') ;
target_list = newList('.ttxfolder','Apk','Applications','Automagic','Kalender','Kontakte','READ-Backups.txt','READ-Dropsync.txt','Test','Timesheet') ;

removeAllElementValues(target_list,source_list);
target_list contains [READ-Backups.txt, Test]

Re: Sync directory script

Posted: 18 Dec 2019 21:58
by OsunSeyi
http://automagic4android.com/flow.php?i ... d01df0f049

Here the flow!
I modified the strings, but still the same result:

Code: Select all

source_files:
'.ttxfolder','Apk','Applications','Automagic','Kalender','Kontakte','READ-Dropsync.txt','READ-Restore.txt','Timesheet'

source_list:
['.ttxfolder','Apk','Applications','Automagic','Kalender','Kontakte','READ-Dropsync.txt','READ-Restore.txt','Timesheet']

~~~~~~~~~~~~~~~~~~~
target_files:
'.ttxfolder','Apk','Applications','Automagic','Kalender','Kontakte','READ-Backups.txt','READ-Dropsync.txt','Test','Timesheet'

target_list:
['.ttxfolder','Apk','Applications','Automagic','Kalender','Kontakte','READ-Backups.txt','READ-Dropsync.txt','Test','Timesheet']

~~~~~~~~~~~~~~~~~~~~
elements_to_delete = removeAllElementValues(target_list,source_list);

elements_to_delete:
['.ttxfolder','Apk','Applications','Automagic','Kalender','Kontakte','READ-Backups.txt','READ-Dropsync.txt','Test','Timesheet']

Re: Sync directory script

Posted: 18 Dec 2019 23:22
by anuraag
This script you used isn't the way to generate a newList.

Code: Select all

source_files = replaceAll(source_files, '\\[', "'");
source_files = replaceAll(source_files, '\\]', "'");
source_files = replaceAll(source_files, source, '');
source_files = replaceAll(source_files, ', ', "','");
source_files = replaceAll(source_files, '/', '');
source_list  = newList(source_files);
Replace above code with

Code: Select all

source_list = newList();
for (i in source_files)
{
	addElement(source_list, replace(i, source, ""))
}
Do similar for target_list.

Re: Sync directory script

Posted: 19 Dec 2019 01:36
by jassing
As pointed out, you're not using lists right. See my code as an alternate example

Re: Sync directory script

Posted: 19 Dec 2019 08:09
by OsunSeyi
Thank's a lot, I. think I got it now.
For testing the output, I'm using this:

http://automagic4android.com/flow.php?i ... bfb214ffe4

Is there a more easy way creating flows and testing the output of each step? I find it very hard typing on the smartphone, and testing what I'm writing on the fly!
I'm using Minuum, which is nice.

Re: Sync directory script

Posted: 21 Dec 2019 16:30
by Desmanto
If typing on smartphone is too difficult, you can mirror your phone to the PC and type from there. Use scrcpy : viewtopic.php?f=5&t=8394&p=26412#p26412

Re: Sync directory script

Posted: 21 Dec 2019 17:55
by OsunSeyi
8-)
Thank's a lot & happy xmas

Re: Sync directory script

Posted: 22 Dec 2019 04:21
by jassing
What about using TeamViewer?

Re: Sync directory script

Posted: 22 Dec 2019 10:11
by Desmanto
I never use teamviewer. But I know it is similar to VNC. And VNC is quite laggy if android is the server, it also require root (AFAIK). The control can't be passed properly. While scrcpy only use adb, can be done wirelessly (after redirect the port or using root), have integrated shortcut for input and you can customize a lot of the feature. Also it can be done offline, without any internet or wifi (if you use USB cable only). Framerate is also much better and smoother.