I have many files inside a folder with
.txt extension. Now they are named randomly by an app but I want to rename each text file to some words written in those files itself after words
Name: but before word
A file named
This is just a test file containing info of each persons. Name: Pearson Bratts Age: 55 Profession:Technician
Now I want the above file to be renamed to
Pearson Bratts.txt using Tasker or any other script app with working script.
The complete shell script follows. You need a Terminal emulator, but I'll leave that to you.
if [ "$1" == "$(cat /dev/null)" ]; then
echo "Usage: $0 <file>"
mv "$1" "$content.txt"
This is to be saved in a something.sh
, which, when executed, will require an additional parameter. For example, we'll assume you'll call it renamer.sh
, and thus the usage will be:
. It'll rename the file you give it, accordingly to its content. To give it the correct file, is your responsibility, and it works for only a file per execution. It won't work if the file has spaces inside its name.