使用脚本重命名android rooted手机上的文件

时间:2021-07-04 10:33:00

I have an android phone and I keep downloading some media files which I would not want to appear in gallery. Don't think me absurd here. In order to accomplish this task, I have written a small & easy script. Here it is.

我有一个Android手机,我不断下载一些我不想在画廊中出现的媒体文件。不要以为我在这里荒谬。为了完成这项任务,我写了一个小而简单的脚本。这里是。

echo "Below files will be hidden."
for fName in `ls /storage/extSdCard/Download/*.mp4`
do
echo $fName
mv -f $fName `basename $fName .mp4`.bak
done

When I execute this script using "File Explorer" application's "Script executor" utility with root user, I get an error message as below.

当我使用“文件资源管理器”应用程序的“脚本执行器”实用程序与root用户执行此脚本时,我收到如下错误消息。

mv: can't create 'abc.mp4': Read-only file system

I assume "root" user has free run in unix/linux based systems. Can anybody guide me on this?

我假设“root”用户可以在基于unix / linux的系统中*运行。任何人都可以指导我吗?

2 个解决方案

#1


0  

The folder that abc.mp4 intended to be placed in, is probably Read-only for all users. Use the command ls -l in parent folder to check.

打算放入abc.mp4的文件夹,对于所有用户来说可能都是只读的。使用父文件夹中的命令ls -l进行检查。

If you want the abc.mp4 in the folder, use chmod to change the folder permission first. For example, if the folder is named folder:

如果您想在文件夹中使用abc.mp4,请先使用chmod更改文件夹权限。例如,如果文件夹名为folder:

chmod +wx folder

w for write permission, x for execute permission. You can run your script smoothly after the permission change.

w表示写入权限,x表示执行权限。您可以在权限更改后顺利运行脚本。

#2


0  

Android has a built-in option for 'hiding' media files such as .MP3 and .JPG from appearing in the gallery of Media Applications.

Android有一个内置选项,用于“隐藏”媒体文件,如.MP3和.JPG,以显示在媒体应用程序的库中。

All you need to do is create a blank file called .nomedia and place it in the same directory as the media files you wish to 'hide'.

您需要做的就是创建一个名为.nomedia的空白文件,并将其放在与您要“隐藏”的媒体文件相同的目录中。

So depending on your requirements it may be easier to change your script to just move the files to a different directory and place a .nomedia file in it.

因此,根据您的要求,可能更容易将脚本更改为将文件移动到其他目录并在其中放置.nomedia文件。

#1


0  

The folder that abc.mp4 intended to be placed in, is probably Read-only for all users. Use the command ls -l in parent folder to check.

打算放入abc.mp4的文件夹,对于所有用户来说可能都是只读的。使用父文件夹中的命令ls -l进行检查。

If you want the abc.mp4 in the folder, use chmod to change the folder permission first. For example, if the folder is named folder:

如果您想在文件夹中使用abc.mp4,请先使用chmod更改文件夹权限。例如,如果文件夹名为folder:

chmod +wx folder

w for write permission, x for execute permission. You can run your script smoothly after the permission change.

w表示写入权限,x表示执行权限。您可以在权限更改后顺利运行脚本。

#2


0  

Android has a built-in option for 'hiding' media files such as .MP3 and .JPG from appearing in the gallery of Media Applications.

Android有一个内置选项,用于“隐藏”媒体文件,如.MP3和.JPG,以显示在媒体应用程序的库中。

All you need to do is create a blank file called .nomedia and place it in the same directory as the media files you wish to 'hide'.

您需要做的就是创建一个名为.nomedia的空白文件,并将其放在与您要“隐藏”的媒体文件相同的目录中。

So depending on your requirements it may be easier to change your script to just move the files to a different directory and place a .nomedia file in it.

因此,根据您的要求,可能更容易将脚本更改为将文件移动到其他目录并在其中放置.nomedia文件。