Results 1 to 10 of 10

Thread: Filename rules/limitations

  1. #1
    Join Date
    Nov 2007
    Beans
    115

    Exclamation Filename rules/limitations

    I am in the process of moving out of Windows and into Ubuntu as completely as possible. One of the problems I am having to deal with has to do with filenames. I had given names starting with a period sign ('.') to a large number of files in Windows over the years ... they will easily run into the hundreds ... mainly to keep them at the top in their respective directories. Now that I am in Ubuntu 12.04 LTS, I can't see them at all. If I go back to Windows and delete the period signs, they show up nicely in Ubuntu. But it's next to impossible ... well, extremely time-consuming ... to change the names of all those hundreds of files. Wondering if there's a way around this. Would really appreciate some help. Thanks!

  2. #2
    Join Date
    Dec 2005
    Location
    Western Australia
    Beans
    11,480
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Filename rules/limitations

    There are several bulk renamer utilities in the Ubuntu Software Center that you could try.

    Or maybe somebody here could quickly knock up a three-line Bash script to remove the periods?
    I try to treat the cause, not the symptom. I avoid the terminal in instructions, unless it's easier or necessary. My instructions will work within the Ubuntu system, instead of breaking or subverting it. Those are the three guarantees to the helpee.

  3. #3
    Join Date
    Jul 2007
    Location
    Brisbane Australia
    Beans
    128
    Distro
    Kubuntu 8.04 Hardy Heron

    Re: Filename rules/limitations

    In Linux, putting a period at the start of a folder name or file name signifies it is a hidden folder or file.

  4. #4
    Join Date
    Nov 2007
    Beans
    115

    Re: Filename rules/limitations

    Thanks, 3rdalbum! Will try that.

  5. #5
    Join Date
    Apr 2012
    Beans
    6,045

    Re: Filename rules/limitations

    You could use the perl-based 'rename' utility

    CAUTION: this will attempt to rename ALL 'dot files' in the current directory including any legitimately hidden system / application configuration files
    ONLY RUN IT IN A DIRECTORY IF YOU ARE SURE THE ONLY 'DOT FILES' ARE YOUR OWN WINDOWS DATA FILES
    IN PARTICULAR DON'T RUN IT IN THE TOP LEVEL OF YOUR HOME DIRECTORY

    Code:
    GLOBIGNORE=.:.. ; rename -nv -- 's/^\.//' .*
    I've left a '-n' switch in which is a dry-run (no op) - check the list of files it says it has renamed (it hasn't ... yet) and if they are all good then remove the 'n' and run it again

  6. #6
    Join Date
    Nov 2007
    Beans
    115

    Re: Filename rules/limitations

    Got it. Thanks, davetv. Won't make that mistake now.

  7. #7
    Join Date
    Nov 2007
    Beans
    115

    Re: Filename rules/limitations

    Great! Thanks, steeldriver!

  8. #8
    Join Date
    Jan 2007
    Location
    England
    Beans
    45
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Filename rules/limitations

    If you're viewing the directory in the nautilus browser, hit Ctrl+H to toggle viewing hidden files. If it's through a terminal, add the -a switch, i.e. ls -la .

  9. #9
    Join Date
    Dec 2005
    Location
    Western Australia
    Beans
    11,480
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Filename rules/limitations

    I thought somebody would quickly knock up a small Bash script to automate the job, in the end I wrote an eight-line Python script. It will look at a directory that you specify and rename all the files that have a period at the beginning of the filename, so it no longer has a period at the beginning of the filename.

    Instructions for use are inside the file.

    I haven't done major testing of the script and it will not work around errors (what do you expect in eight lines!) but it should work well enough for most scenarios. The warnings Steeldriver gave you also apply to this script.
    Attached Files Attached Files
    Last edited by 3rdalbum; August 12th, 2013 at 01:55 PM.
    I try to treat the cause, not the symptom. I avoid the terminal in instructions, unless it's easier or necessary. My instructions will work within the Ubuntu system, instead of breaking or subverting it. Those are the three guarantees to the helpee.

  10. #10
    Join Date
    Nov 2007
    Beans
    115

    Re: Filename rules/limitations

    Thanks, 3rdalbum and all others. I got myself pyRenamer, KRename and PrefixSuffix. The first two confused me. As for the third, after a couple of trial-and-error runs, I think I have the hang of it finally.

    Tomorrow's projects for myself - to try out your codes, and also to find out how to keep those priority files at the top of their respective directories, obviously without the period sign. I have tried with a '~' prefix but it doesn't work. Works in Windows, but that's beside the point.

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
  •