Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: looking for script to remove spaces from filenames

  1. #1
    Join Date
    May 2007
    Location
    Townsville, Australia
    Beans
    1,820
    Distro
    Lubuntu 14.04 Trusty Tahr

    looking for script to remove spaces from filenames

    i dont know if it can be done, but im chasing a script that can read a directory and read the filenames and remove all the spaces and replace the spaces with a .

    example

    this file needs to be changed

    this.file.needs.to.be.changed


    can it be done??

    thanks
    Ubuntu user # 16304 www.nocleanfeed.com
    If someone asks you to sudo rm -rf anything, don't do it, and don't run any command with rm in it unless you know exactly what you're doing.things i have learnt changing from Xp pro to Ubuntu

  2. #2
    Join Date
    Oct 2006
    Location
    Lyon, France
    Beans
    839
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: looking for script to remove spaces from filenames

    When in the directory :

    Code:
    rename -n 's/ /./g' *
    Run it (it won't rename the files yet), check that it does what it's supposed to, then run it again without the -n so it actually renames the files.
    This is the first age that's paid much attention to the future, which is a little ironic since we may not have one.
    -- Arthur C. Clarke

  3. #3
    Join Date
    May 2007
    Location
    Townsville, Australia
    Beans
    1,820
    Distro
    Lubuntu 14.04 Trusty Tahr

    Re: looking for script to remove spaces from filenames

    awesome.thanks
    Ubuntu user # 16304 www.nocleanfeed.com
    If someone asks you to sudo rm -rf anything, don't do it, and don't run any command with rm in it unless you know exactly what you're doing.things i have learnt changing from Xp pro to Ubuntu

  4. #4
    Join Date
    Oct 2007
    Location
    Cincinnati, Ohio
    Beans
    Hidden!
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: looking for script to remove spaces from filenames

    Just fyi there is a gui for renaming in synaptic, just search for pyrenamer and install. I have found it quite handy. You can also CLICK HERE to install it.

    OS: Kubuntu 12.04 LTS|| CPU: AMD Athlon 64x2 || RAM: 3GB DDR2(PC-6400) || Display: NVIDIA GeForce 9400 GT 1024mb

  5. #5
    Join Date
    May 2007
    Location
    Townsville, Australia
    Beans
    1,820
    Distro
    Lubuntu 14.04 Trusty Tahr

    Re: looking for script to remove spaces from filenames

    thanks for the info Angel
    Ubuntu user # 16304 www.nocleanfeed.com
    If someone asks you to sudo rm -rf anything, don't do it, and don't run any command with rm in it unless you know exactly what you're doing.things i have learnt changing from Xp pro to Ubuntu

  6. #6
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: looking for script to remove spaces from filenames

    Quote Originally Posted by Mornedhel View Post
    When in the directory :

    Code:
    rename -n 's/ /./g' *
    Run it (it won't rename the files yet), check that it does what it's supposed to, then run it again without the -n so it actually renames the files.
    rename is not available everywhere.if you don't have it, a simple bash script should do the trick:

    Code:
    find /path/to/dir -type f -iname "* *" | \
    while read file; do \
    echo mv "${file}" "${file// /.}"; \
    done
    (remove the echo command to actually rename the files)
    NOTE: find will search for files in /path/to/dir recursively.

    gprename, pyrenamer, thunar (file manager) and krename are GUI renamer tools.
    Last edited by sisco311; June 19th, 2009 at 01:01 PM.

  7. #7
    Join Date
    Oct 2006
    Location
    Lyon, France
    Beans
    839
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: looking for script to remove spaces from filenames

    Quote Originally Posted by sisco311 View Post
    rename is not available everywhere.
    This is true, but it's been available out of the box in every Ubuntu since Dapper Drake at least.
    This is the first age that's paid much attention to the future, which is a little ironic since we may not have one.
    -- Arthur C. Clarke

  8. #8
    Join Date
    Mar 2008
    Location
    Connecticut
    Beans
    940
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: looking for script to remove spaces from filenames

    Quote Originally Posted by stinger30au View Post
    i dont know if it can be done, but im chasing a script that can read a directory and read the filenames and remove all the spaces and replace the spaces with a .

    example

    this file needs to be changed

    this.file.needs.to.be.changed


    can it be done??

    thanks
    You could also install purrr
    Code:
    sudo apt-get install purrr
    it's a GUI batch renaming app.
    http://packages.ubuntu.com/hardy/utils/purrr
    It's available in both Ibex and Jaunty.

    Bill
    Ubuntu 10.04-Server: HP Pavilion: AMD Athlon 3200; 2gb RAM; GeForce4 MX - nForce; 160gb HDD; 1TB eSATA External HDD | Ubuntu 10.04: Dell D600; Intel Pentium M 1600 MHz; 2gb RAM; ATI Radeon 9000 (RV250); 60gb HD | Ubuntu User #24614

  9. #9
    Join Date
    May 2007
    Location
    Townsville, Australia
    Beans
    1,820
    Distro
    Lubuntu 14.04 Trusty Tahr

    Re: looking for script to remove spaces from filenames

    thanks all that have responded

    i have got the job done in a matter of seconds now.

    i was dredding renaming a few thousand files by hand
    Ubuntu user # 16304 www.nocleanfeed.com
    If someone asks you to sudo rm -rf anything, don't do it, and don't run any command with rm in it unless you know exactly what you're doing.things i have learnt changing from Xp pro to Ubuntu

  10. #10
    Join Date
    Sep 2006
    Beans
    2,914

    Re: looking for script to remove spaces from filenames

    if you have Python (2.4++), you can use the script i have (see my sig last link called File renamer)
    usage
    Code:
    # python filerenamer.py -p " " -e "." -l "*"
    remove the "-l" option to commit changes. use -h option to see more functions of the script.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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