Here I am again, struggling against my huge programming limitation.
I need a simple script to use it in a NOT triggered flow ( I need to use it manually or executed by another flow),
to move and rename multiple FILES form directory A to directory B , and adding the suffix MOVED to their original names.
I'm trying to init Variable File List but then i'm not able to use the content of that variable
If someone has some time to waist, thank you.
Rename/move multiple files script
Moderator: Martin
Re: Rename/move multiple files script
The solution still using Init variable file list, to get the file list in the folder source. But we can't use action move files directly, since for multiple files, we have to mention a directory, which mean the source file name and destination file name will be the same. To make it different in each individual files and without looping action move files, we can simply use execute command, mv. (no root). We need to loop the list first in script, creating the lines of command before passing to execute command.
line store every command to move the file. Target is the path of destination. The loop add all element and its renamed version to the line. The renamed name is found by using replaceAll regex, added with _MOVED before the extention.
After this script, add Execute command and use
{line,listformat}
in the command field.
Code: Select all
line = newList();
target = "/storage/emulated/0/data/";
for(i in files)
addElement(line, "mv '" + i + "' '" + replaceAll(i, "/.*/(.*)(\\..*)", "{target}$1_MOVED$2'") );
After this script, add Execute command and use
{line,listformat}
in the command field.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Rename/move multiple files script
Thank you thank you thank you Desmanto!
It works perfectly, the only thing to say is that , to me,
if the target directory is on the external SD I need to perform an "execute root command"
instead of a simple "execute command" due to a "permission denied" error.
Thank you really a lot!
It works perfectly, the only thing to say is that , to me,
if the target directory is on the external SD I need to perform an "execute root command"
instead of a simple "execute command" due to a "permission denied" error.
Thank you really a lot!