What is mv in post below - Rename file/folder

tdocs2

Well-Known Member
Licensed User
Longtime User
This was a wonderful and very useful sub posted by Margret (110653). Thank you, Margret.

The sub works GREAT! The question is what is the "mv " app that is the target of the Shell?

The desolatesoul was kind enough to send me the core code of which I created this sub. I have tested it with files up to 1.5gig. You must pass the full path and file name for the original and the new file. It returns True if the file was renamed and False if it was not.

Uses the Phone library

Call with:

B4X:
RenameFile("/mnt/sdcard/Movies/Monsters_HQ.mp4", "/mnt/sdcard/Movies/M_HQ.mp4")

B4X:
Sub RenameFile(OriginalFileName As String, NewFileName As String) As Boolean
   Dim Result As Int
   Dim StdOut, StdErr As StringBuilder
   StdOut.Initialize
   StdErr.Initialize
   Dim Ph As Phone
   Result = Ph.Shell("mv " & OriginalFileName & " " & NewFileName, Null,  StdOut, StdErr)
   If Result = 0 Then
      Return True
   Else
      Return False
   End If
End Sub

Margret:D
 

mc73

Well-Known Member
Licensed User
Longtime User
M(o)V(e) is the move/rename shell command.
You can see some other commands as well, here.
 
Last edited:
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
Thanks, MC

Thanks, MC.

Useful addendum in pointing to Basic Shell Commands...
 
Upvote 0
Top