Rename multiple hidden files

Discussion in 'Mac Programming' started by ampires, Nov 13, 2010.

  1. macrumors newbie

    Nov 13, 2010
    I was given a folder with around a thousand files in it to work on from someone on windows. When I open the folder there are no files. I figured out that the windows program named them all beginning with a period, which makes them hidden in mac. I am trying to use a shell script to add a letter at the beginning of all of them so I can see them.

    I've been using this code with the directory with the hidden files as cd:
    for i in .*; do mv "$i" "x$i"; done;

    i'm trying to add an x to the beginning, but its not working.

    If anyone has experience with hidden files it would be appreciated
  2. macrumors 604

    Aug 9, 2009
    Remember that the directories "." and ".." match the pattern. You will not be able to rename these.

    Personally, I'd use the 'find' command, because it has tests like "is a file", and logical predicates. It would be perfectly capable of execing a 'mv' command.

    And you should probably look into why the filenames all start with ".", unless you know for certain it's just a quirk of the programmer. Dotted filenames suggest something unexpected, which might be something like an archival format, a source-code control system, etc.
  3. Moderator


    Staff Member

    Aug 16, 2005
    New England
    ls -a
    within terminal will show hidden files to see if that is really your problem.

    You might also want to look at the man page for find. (EDIT:chown33 beat me to it)


Share This Page