FedoraForum.org - Fedora Support Forums and Community
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2018
    Location
    California
    Posts
    12

    Totally baffeled with remane function /usr/bin/rename

    Okay like I have some torrents and due to a learning error on importing them in qBittorrent I have all torrent files as Filename.torrent.added
    So I take it I was half right on importing these but I should have forced check instead of cancel.
    Now I am trying to rename 236 torrent files so I can try again.
    So how in the heck do I use rename? Nothing I read makes sense as I always get the error rename: invalid option -- 'A'
    Any advice on importing torrents accepted too.

  2. #2
    Join Date
    Dec 2007
    Location
    Australia
    Posts
    1,670

    Re: Totally baffeled with remane function /usr/bin/rename

    Not sure if I quite get your issue, but if you wish to rename 'filename.torrent.added' to just 'filename' (assuming they all have a different filename), then you could run something like the following with all the relevant files in the one directory:
    Code:
    for i in `ls`;do mv $i `echo $i|cut -d. -f1`; done
    which should just leave you with 'filename' for each file.

  3. #3
    Join Date
    Oct 2011
    Posts
    1,666

    Re: Totally baffeled with remane function /usr/bin/rename

    A filename could have more dots in name. A more robust solution would be to cut from the right. The way to achieve that is with `rev`. Also no need for 'ls' since it is possible to refer to files directly.

    Code:
    for fn in *.added; do mv $fn $(echo $fn | rev | cut -d. -f2- | rev); done

  4. #4
    Join Date
    Aug 2011
    Location
    ~
    Posts
    1,906

    Re: Totally baffeled with remane function /usr/bin/rename

    rename .torrent.added .torrent ./*.torrent*

  5. #5
    Join Date
    Jan 2018
    Location
    California
    Posts
    12

    Re: Totally baffeled with remane function /usr/bin/rename

    Okay Dutchy had the right suggestion for rename.
    Confusing to say the least. Something about Perl stuff.
    Thank You nsnbm and srakitnican.

  6. #6
    Join Date
    Dec 2007
    Location
    Australia
    Posts
    1,670

    Re: Totally baffeled with remane function /usr/bin/rename

    srakitnican wrote:
    Code:
    for fn in *.added; do mv $fn $(echo $fn | rev | cut -d. -f2- | rev); done
    Thanks for that. Alas, I'm no bash scripter of substance, but I do appreciate that one.

  7. #7
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    596

    Re: Totally baffeled with remane function /usr/bin/rename

    Quote Originally Posted by nsnbm
    srakitnican wrote:
    Code:
    for fn in *.added; do mv $fn $(echo $fn | rev | cut -d. -f2- | rev); done
    Thanks for that. Alas, I'm no bash scripter of substance, but I do appreciate that one.
    Or (just echoing as an example, not moving):

    Code:
    # for file in foo.baa.txt something.else.doc; do echo ${file%.*}; done
    foo.baa
    something.else
    Or as all the files here end in ".added" basename is perfect:

    Code:
    # for file in foo.baa.added something.else.added; do basename $file .added; done
    foo.baa
    something.else

Similar Threads

  1. Totally not cool ...
    By Dan in forum Wibble
    Replies: 22
    Last Post: 30th June 2014, 03:29 PM
  2. Totally confused with LVM on fc7
    By tvoltagg in forum Using Fedora
    Replies: 1
    Last Post: 7th March 2008, 01:54 AM
  3. That was totally epic.
    By forkbomb in forum Linux Chat
    Replies: 7
    Last Post: 10th January 2008, 05:36 PM
  4. HELP!!! Yum totally broken
    By craigni in forum Using Fedora
    Replies: 19
    Last Post: 14th October 2006, 04:13 AM
  5. Totally new to this.
    By S3xyNaniGoat in forum Servers & Networking
    Replies: 10
    Last Post: 2nd April 2005, 03:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •