Page 1 of 1

Use 'Rename' command in terminal? (Solved)

Posted: Thu May 13, 2021 4:19 pm
by Clarity

I am trying to use the 'rename' terminal command and need help.

I have 3 files in a folder: Class.txt Agenda.txt Notes.txt

I want to RENAME the 3 files, automatically, to filenames without the ".txt".

In a terminal (on FossaPUP64/Slacko64), I do the following:

Code: Select all

# cd folder
# ls
Agenda.txt  Class.txt  Notes.txt
# rename 's/.txt//' *
# ls
Agenda.txt  Class.txt  Notes.txt

The filenames remain the same no matter the rename operator I use.

Can anyone guide me to correct use of the rename command, please?


Re: RENAME command use

Posted: Thu May 13, 2021 4:26 pm
by tosim

I suggest: Open terminal, type "man rename" without quotes, and it will give you the info.


Re: RENAME command use

Posted: Thu May 13, 2021 4:33 pm
by Clarity

Have you tried that?


Re: How to use 'Rename' command in terminal?

Posted: Thu May 13, 2021 5:09 pm
by Flash

I just entered 'rename --help' into a Sakura console and got this:

Code: Select all

# rename --help

Usage:
 rename [options] <expression> <replacement> <file>...

Rename files.

Options:
 -v, --verbose       explain what is being done
 -s, --symlink       act on the target of symlinks
 -n, --no-act        do not make any changes
 -o, --no-overwrite  don't overwrite existing files
 -i, --interactive   prompt before overwrite

 -h, --help          display this help
 -V, --version       display version

For more details see rename(1).
# 

I typed 'man rename' into a Sakura console and it sent me here: https://linux.die.net/man/3/rename


Re: How to use 'Rename' command in terminal?

Posted: Thu May 13, 2021 5:35 pm
by misko_2083

It takes a few seconds to find an anwser with my Nokia 2.1 with this Googleware on top of linux kernel. https://unix.stackexchange.com/question ... sion#34550

I would usually use mv instead, but since your choice is rename here's the online manual
https://www.man7.org/linux/man-pages/man1/rename.1.html


Re: How to use 'Rename' command in terminal?

Posted: Thu May 13, 2021 5:45 pm
by Clarity

The problem I am having is that the command implementation is not working.

I AM wondering if it is a bug or a command misuse. There are no error messages, so I am clueless and appealing for help/insights.

Anyone else tried to do such? Did it work on your system?

Curious. Thanks in advance.


<Solution> Use of 'Rename' command in terminal?

Posted: Thu May 13, 2021 6:03 pm
by Clarity

Looks like there is 2 LInux RENAME commands
For FossaPUP64 & Slacko64, the following syntax works:

Code: Select all

rename -- .txt  '' *

Where

  1. "-- .txt" is what you want to scan for

  2. and " '' " is what you those found to change to

  3. '*' is for all filenames found in the folder.

Thanks for all attempts to help me.

P.S. The command is "lightening" fast for small use or large number of filenames.


Re: Use 'Rename' command in terminal? (Solved)

Posted: Fri May 14, 2021 12:44 am
by Flash

Rox Filer has an excellent batch rename function. Check it out. In Rox, highlight the group of files you want to rename, right-click and choose Rename.