Dynamic File Locations

SreudianFlip01

New member
I would like to move files around my phone in bulk. The current copy and move file actions require a file to be specified. I would rather the action take a variable for the file name and file location so that I can have greater control over where my files are moved.

Thank you for your time! Love this app!
 

iwally

Member
I would like to move files around my phone in bulk. The current copy and move file actions require a file to be specified. I would rather the action take a variable for the file name and file location so that I can have greater control over where my files are moved.

Thank you for your time! Love this app!
Same for me: tried with cp / mv in Shell Script Action, but for some reasons they do not work
See my post Move file: Operation not permitted
 

iwally

Member
I'm still confused why it doesn't work for you. It works for me (Redmi Note 11 Android 13 on MIUI 14.0.1). Did you confirm all the permissions for helper are enabled ?
View attachment 6944

Hello @Endercraft
this is one of the things they suggested me to check: see the attachment to this post

We tried in several ways, by cp and mv always resulted in:

"timed out" > with the flag "Use Helper App"
"operation not permitted" > without the flag

These, despite the directory:

been created outside Android stardard folders
been successfully writter in by File Operation Action type "Copy"

That's why I hope the "destination" file could become a variable ;-)
Thanks
 

Dimlos

Well-known member
The @iwally problem may also be possible with another shell, e.g. Termux.
However, since this is usually possible with MD shell scripts, it may not work even if the program is modified if the cause is not identified.
 

iwally

Member
The @iwally problem may also be possible with another shell, e.g. Termux.
However, since this is usually possible with MD shell scripts, it may not work even if the program is modified if the cause is not identified.
I agree ... if you cannot measure it, you cannot Fix it!

But what other could I share to help investigations?

The only thing came to my mind is I have a work profile, managed by my company.
Could this influence MD Shell Script behaviour?
But why can File Operation Acrion work in the same dir?

Anyhow this app instance is In my personal profile. As the dir ktself: it was created with the file manager app in thr private profile.
Thanks Again
 
Last edited:

sampleuserhere

Active member
That explains why, afaik different user couldn't rewrite other file written by other user. Maybe somone else could explain it better for work profile.

anyway, IIRC someone did suggest you to check the attributes of the file/folder, have you tried that already?

Code:
ls -l "folder/file full path"

But what other could I share to help investigations?

Ideally your OS information, the way the file is created, why you want to do A, why A is the solution you came up with, etc.

 

iwally

Member
That explains why, afaik different user couldn't rewrite other file written by other user. Maybe somone else could explain it better for work profile.

anyway, IIRC someone did suggest you to check the attributes of the file/folder, have you tried that already?

Code:
ls -l "folder/file full path"



Ideally your OS information, the way the file is created, why you want to do A, why A is the solution you came up with, etc.

 

iwally

Member
This is the resukt of ls -l on file /storage/emulated/0/_MyDir/_random.mp3 (the one we are supposed to copy / rename) taken from the Shell Script output

Code:
-rw-rw---- 1 u0_a269 media_rw 9900683 2023-09-25 06:20 /storage/emulated/0/_MyDir/_random.mp3

This is the result of ls -l on (the one we are supposed to overwrite)
Code:
-rw-rw---- 1 u0_a269 media_rw 19110051 2023-09-02 17:04 /storage/emulated/0/_MyDir/_fixname.mp3

This is the resukt of ls -l into my dir /storage/emulated/0/_MyDir/

Code:
total 29554drwxrws--- 7 u0_a269 media_rw     3452 2023-09-12 10:00 Documentsdrwxrws--- 2 u0_a269 media_rw     4096 2023-09-24 22:16 NaturalSoundsdrwxrws--- 4 u0_a269 media_rw     3452 2023-09-12 09:42 Podcasts-rw-rw---- 1 u0_a269 media_rw 19110051 2023-09-02 17:04 _fixname.mp3-rw-rw---- 1 u0_a269 media_rw  1205312 2023-09-25 20:56 _random.jpg-rw-rw---- 1 u0_a269 media_rw  9900683 2023-09-25 06:20 _random.mp3

The attached print screen is the dir structure


I have a Galaxy S23+ with Android 13 and OneUI 5.1.
Thanks
 

Attachments

  • 1696230133887.jpeg
    1696230133887.jpeg
    184.5 KB · Views: 1

LinerSeven

Active member
Hi, @iwally.

Thank you for the information you have provided.

The files under _MyDir appear to have permissions without any problems.

If you do "ls -l /storage/emulated/0/",
What are the permissions on the _MyDir folder itself?


Also, using a shell script,
"chmod 777 _MyDir"
Does the above command work on your mobile phone?

Best Regards,
Liner Seven
 

iwally

Member
Hi, @iwally.

Thank you for the information you have provided.

The files under _MyDir appear to have permissions without any problems.

If you do "ls -l /storage/emulated/0/",
What are the permissions on the _MyDir folder itself?


Also, using a shell script,
"chmod 777 _MyDir"
Does the above command work on your mobile phone?

Best Regards,
Liner Seven

Hello @LinerSeven
This is the output: hope not too confusing

Code:
total 71drwxrws---   2 u0_a269  media_rw  3452 2023-03-24 10:02 Alarmsdrwxrws--x   6 media_rw media_rw  3452 2023-09-12 14:08 Androiddrwxrws---   2 u0_a269  media_rw  3452 2023-03-24 10:02 Audiobooksdrwxrws---   5 u0_a269  media_rw  3452 2023-09-12 09:38 DCIMdrwxrws---   3 u0_a269  media_rw  3452 2023-09-12 10:58 Documentsdrwxrws---   5 u0_a269  media_rw  4096 2023-09-26 08:18 Downloaddrwxrws---   3 u0_a269  media_rw  3452 2023-09-12 10:00 DualMediaBackupdrwxrws---   4 u0_a269  media_rw  3452 2023-09-12 10:00 MediaMonkeydrwxrws---   3 u0_a269  media_rw  3452 2023-03-24 10:02 Moviesdrwxrwxr-x 329 media_rw media_rw 20480 2023-09-23 20:16 Musicdrwxrws---   2 u0_a269  media_rw  3452 2023-09-12 09:59 Notificationsdrwxrws---   6 u0_a269  media_rw  3452 2023-09-14 21:44 Picturesdrwxrws---   2 u0_a269  media_rw  3452 2023-03-24 10:02 Podcastsdrwxrws---   3 u0_a269  media_rw  3452 2023-09-12 09:56 Recordingsdrwxrws---   2 u0_a269  media_rw  3452 2023-09-12 09:58 Ringtonesdrwxrws---   3 u0_a269  media_rw  3452 2023-09-12 09:56 Samsungdrwxrws---   3 u0_a269  media_rw  3452 2023-09-12 11:01 SmartSwitchdrwxrws---   5 u0_a269  media_rw  3452 2023-09-12 13:54 Telegramdrwxrws---   5 u0_a269  media_rw  3452 2023-10-02 08:57 _MyDir

I execute chmod specifying full path: hope you meant this. The result is permission denied.


Code:
chmod: chmod '/storage/emulated/0/_MyDir' to 0777: Permission denied

Thanks
 

iwally

Member
Can you also give result of id command?

Sorry I'm not sure what you asked for was this.

Code:
uid=10369(u0_a369) gid=10369(u0_a369) groups=10369(u0_a369),3001(net_bt_admin),3002(net_bt),3003(inet),9997(everybody),20369(u0_a369_cache),50369(all_a369) context=u:r:untrusted_app:s0:c113,c257,c512,c768

Let me know if I misunderstood what you asked for.
Thanks
 

iwally

Member
Hi, @iwally.

You have a different folder owner id (u0_a269) running id (u0_a369).

Could you recreate the target folder with the currently running user?

Best Regards,

Liner Seven

Hello @LinerSeven
what I did was:

1. Rename /storage/emulated/0/_MyDir to /storage/emulated/0/_MyDirOLD
2. Create a new /storage/emulated/0/_MyDir
3. Moved all files from /storage/emulated/0/_MyDirOLD to /storage/emulated/0/_MyDir

But I still have "timed out" (with flag "Use Helper App") "Operation not permitted" (without).

This is the id command output

Code:
uid=10369(u0_a369) gid=10369(u0_a369) groups=10369(u0_a369),3001(net_bt_admin),3002(net_bt),3003(inet),9997(everybody),20369(u0_a369_cache),50369(all_a369) context=u:r:untrusted_app:s0:c113,c257,c512,c768

What am I missing?
This phone comes from the "copy" of another Galaxy, but these MP3 were added later, after the migration, via USB connection (with the cable)

Thanks again
 

Endercraft

Moderator (& bug finder :D)
Try chmod 777 _MyDir with adb and with normal shell script.
To note, because you are invoking the shell script from MacroDroid the user isn't you, it's MacroDroid. So you might as well delete directory then use mkdir _MyDir from MacroDroid shell script so MacroDroid is the owner of the directory.
I'll try and resolve this when I can.
 

iwally

Member
Try chmod 777 _MyDir with adb and with normal shell script.
To note, because you are invoking the shell script from MacroDroid the user isn't you, it's MacroDroid. So you might as well delete directory then use mkdir _MyDir from MacroDroid shell script so MacroDroid is the owner of the directory.
I'll try and resolve this when I can.
We already tried chmod 777 with no success.

Then I have:

1. renamed _MyDir to _MyDirOLD
2. Run mkdir from MD

The result is "timed out" and "mkdir: '_MyDir': Read-only file system"

With full path:

mkdir: '/storage/emulated/0/_MyDir': Permission denied

Thanks
 

LinerSeven

Active member
Hi, @iwally.

I feel that your response is not wrong.

This phenomenon resembles the case of a Windows NTFS file system mounted on Linux.

If it is just Linux, remounting the file system can make it correct, but I don't know if it can be remounted on Galaxy either.

Then use the chown shell command,
"chown 10369:10369 _MyDir" ... :-(

I apologise for not being able to help you...

Liner Seven
 

iwally

Member
Hi, @iwally.

I feel that your response is not wrong.

This phenomenon resembles the case of a Windows NTFS file system mounted on Linux.

If it is just Linux, remounting the file system can make it correct, but I don't know if it can be remounted on Galaxy either.

Then use the chown shell command,
"chown 10369:10369 _MyDir" ... :-(

I apologise for not being able to help you...

Liner Seven

Hello @LinerSeven
first of all do not apologize: you spent a lot of time trying to help me and I really appreciate!

Tried also "chown 10369:10369 /storage/emulated/0/_MyDir" from MD Shell Script Action.
Timed out.

Unless you were meaning I have to try from a Linux OS, I say once again (as in the original post): I give up.

So let me endorse this feature request: http://www.macrodroidforum.com/index.php?threads/dynamic-file-locations.895/post-32280
Because Copy and Move options of File Operation Action are working as expected: the only missing thing to me is the possibility to change the destination file name!

That would be the solution, to me!
Thanks
 
Top