Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Can this be done with Scripts ??
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Can this be done with Scripts ??

  1. #1
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935

    Can this be done with Scripts ??

    I'm having one problem.

    I was testing out KMail's newly supported "maildir" format mail boxes but decided that I'm more into Sylpheed's MH mail boxes style especally since Sylpheed support importing from mbox style with ease. Kmail create directory with long file names such as 1036119107.1941.eTnT:2,S which Sylpheed could not understand even though I moved mail messages to Sylpheed's inbox folder and rescan it. Sylpheed puts messages in files names such as 1, 2, 3 and so on.

    As a test, I rename the Kmail's long file name from 1036119107.1941.eTnT:2,S to the short format 1 and Sylpheed reads it good, no problem.

    Now the problem is if I have to rename all the mails, I will have to do it 11728 times ( since I have a lot of mailing lists stuff which I like to migrate and preserve it ) and it's this huge task of doing it.

    So can I use the scripts ( I know nothing about scripting ) for this stuff? Either with sed or awk or bash or whatever?? For example, read the file name in this specific folder, if the file name is longer than 8 charactors, then rename it to whichever file names that is one more incremental from the previous renaming? May be with C or C++ program?

    Please help.

    TIA


  2. #2

    Re:Can this be done with Scripts ??

    You mean you have a lot of files named 019287309128Kdsj21 and you want them renamed from 1 to (number of files)?

  3. #3

    Re:Can this be done with Scripts ??

    This will change all names in the current directory to normal number (ie: 000000001 becomes 1, 000000234 becomes 2, etc ...). Run it on a test set to make sure it's what you need.

    Code:
    #!/bin/bash
    TMPVAR=1
    
    for i in *; 
    do 
    if [ $i != 'test.sh' ]; then
    mv $i $TMPVAR;
    TMPVAR=$[TMPVAR + 1];
    fi  
    done

  4. #4
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935

    Re:Can this be done with Scripts ??

    [quote author=GnuVince link=board=9;threadid=5504;start=0#53029 date=1036345435]
    You mean you have a lot of files named 019287309128Kdsj21 and you want them renamed from 1 to (number of files)?
    [/quote]
    Actually, the names are different ( I think it's how KMail's identify mail messages ). So, one message is 123456789.123456.ijKl,S;2 and another is 123456789.123456.ikJE,s;2 and so on. So the difference is only ijKl and ikJE part of it.
    I wanted to rename the first file names which are longer than 8 characters to 1 and then the second file names which are longer than 8 characters to 2 and the next file names which are longer than 8 characters to 3 and so on. So that Sylpheed will read the messages but renaming will not over ride messages ( if the name is the same such as 1, then only the last file will be able to read it, right? )
    Do I make any sense?

    Thanks.

  5. #5
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935

    Re:Can this be done with Scripts ??

    [quote author=Ashcrow link=board=9;threadid=5504;start=0#53076 date=1036376525]
    This will change all names in the current directory to normal number (ie: 000000001 becomes 1, 000000234 becomes 2, etc ...). Run it on a test set to make sure it's what you need.
    [/quote]
    Yeah, thanks. I will try it out.

  6. #6
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935

    Re:Can this be done with Scripts ??

    [quote author=Ashcrow link=board=9;threadid=5504;start=0#53076 date=1036376525]
    This will change all names in the current directory to normal number (ie: 000000001 becomes 1, 000000234 becomes 2, etc ...). Run it on a test set to make sure it's what you need.
    [/quote]
    I tested and it's not exactly what I needed.

    I moved about 10 mails and run the script. It replace all 10 mails with only one file, 1. It wiped the 9 mails that I needed to preserve.
    Code:
    #!/bin/bash
    TMPVAR=1
    
    for i in *; 
    do 
    if [ $i != 'test.sh' ]; then
       mv $i $TMPVAR;
       TMPVAR=$[TMPVAR + 1];
    fi  
    done
    May be I need some kind of loop thing?? Currently, it's replacing ALL files eith only one file.

    Please help. :'(

  7. #7
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re:Can this be done with Scripts ??

    I know this is a long shot, but how about something like:
    Code:
    #!/bin/bash
    TMPVAR=0
    TMPCNT=""
    
    for i in *; 
    do 
    if [ $i != 'test.sh' ]; then
      TMPVAR=`echo $TMPCNT | wc -c`
      mv $i $TMPVAR;
      TMPCNT=".$TMPCNT"
    fi  
    done
    It will assure, the $TMPVAR is climbing, but if you reach MAX_LENGTH of assignment for the $TMPCNT it will start from 0 again.

    I know there is a clever way, but I just can't remember right now.. It has something todo with a 'set' or 'assign' like keyword, the $TMPVAR should be initialized with, else it can't be used as a counter.

  8. #8

    Re:Can this be done with Scripts ??

    Code:
    #!/usr/bin/env ruby
    
    if ARGV.length != 1
      puts "Usage: #$0 <directory>"
      exit 1
    end
    
    my_dir = ARGV[0]
    current_email = 1
    
    Dir.chdir(my_dir)
    Dir.foreach(".") { |file|
      File.rename(file, current_email.to_s)
      current_email += 1
    }
    
    puts "Done."
    Fixed script

  9. #9
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935

    Re:Can this be done with Scripts ??

    GnuVince,

    Since I know nothing about programming ....

    All I do is update <directory> part of it and install ruby to run it??

    TIA

  10. #10

    Re:Can this be done with Scripts ??

    Compunuts:

    You install Ruby, then do:

    Code:
    chmod +x script.rb
    ./script.rb my_dir_full_of_files

Similar Threads

  1. MSN messenager scripts
    By headshock in forum Windows - General Topics
    Replies: 3
    Last Post: 07-05-2005, 04:53 PM
  2. Scripts
    By countach44 in forum Windows - General Topics
    Replies: 8
    Last Post: 05-25-2005, 10:47 PM
  3. Startup scripts
    By cloverm in forum Linux - General Topics
    Replies: 2
    Last Post: 06-20-2003, 03:01 PM
  4. scripts in rc.local
    By jsj1996 in forum Linux - General Topics
    Replies: 2
    Last Post: 02-19-2003, 11:55 PM
  5. creating my own scripts
    By flandercan in forum Programming
    Replies: 9
    Last Post: 05-22-2002, 02:26 AM

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
  •