Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Greetings, I work IT for a school whose mail server died shortly after I started working. Alot of the emails were originally set up as IMAP accounts which meant when ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3

    Massive File rename to remove commas

    Greetings,

    I work IT for a school whose mail server died shortly after I started working. Alot of the emails were originally set up as IMAP accounts which meant when the server died, the users lost the links to their accounts. I have gotten to the files I need to copy over but here's the problem.

    all of the filenames have commas in them. So when I go to copy these emails to my usb drive, i get the error message "too many arguments"

    So I need a script (or anything) that will run through ALL of these directories, and remove the commas from the filenames. But I have no scripting experience in linux and I am short on time! PLEASE HELP!

  2. #2
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    Code:
    [xxx@xxx project1]$ touch 'this,that'
    [xxx@xxx project1]$ touch 'that,this'
    [xxx@xxx project1]$ ls -l
    -rw-rw-r--  1 xxx xxx    0 Oct 18 16:05 that,this
    -rw-rw-r--  1 xxx xxx    0 Oct 18 16:05 this,that
    [xxx@xxx project1]$ rename ',' '' *','*
    [xxx@xxx project1]$ ls -l
    -rw-rw-r--  1 xxx xxx    0 Oct 18 16:05 thatthis
    -rw-rw-r--  1 xxx xxx    0 Oct 18 16:05 thisthat

  3. #3
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    It doesn't seem to me that removing commas from filenames would get rid of an error message like "too many arguments" on a cp command.

    walkblind, did likwid's solution do the trick for you, or does the problem remain?

  4. #4
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    Quote Originally Posted by wje_lf View Post
    It doesn't seem to me that removing commas from filenames would get rid of an error message like "too many arguments" on a cp command.
    I agree, in fact I am hoping the filenames weren't kept in some cache... cause when the server comes back it'll get all kinds of file not found errors, but I don't know enough about imap to say.

  5. #5
    Linux Newbie
    Join Date
    Sep 2007
    Posts
    161
    hi, i also agree with the two posters before me.

    i would archive the files before moving them to the usb drive, e.g. using "zip -r" or "tar" on the directory tree, to take care of the error message concerning "too many arguments".

    kai

  6. #6
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Quote Originally Posted by walkblind
    all of the filenames have commas in them. So when I go to copy these emails to my usb drive, i get the error message "too many arguments"
    I hope you're reading the replies on this thread before messing with any file names. Consensus so far is that your speculation about cause and effect is questionable...

    I'd tar up the files and then move them.

  7. #7
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    Didn't we have a thread before about a limit on the number of files that could be passed to cp?

  8. #8
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I don't remember such a thread for cp exactly, but there is this.

  9. #9
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3

    Exclamation compression

    tar solution sounds viable. I'll give it a shot monday morning and post results. Thank you for suggestions.

  10. #10
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3

    Success!

    It worked! I was able to recover the old emails and be the IT hero for about 10 minutes. Thank you for the ideas!

Page 1 of 2 1 2 LastLast

Posting Permissions

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