Thread: Sweeper

  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Rep Power


    Is it possible to create a perl program to

    1. continuously sweep a named directory for files with a certain extension and rename them with another extension?

    Example: continuously sweep \myfiles for files with the extension of .txt and rename them with the extension of .doc

    I have this need but I am thinking that it needs to be some type of continuous sweeper or continuous loop (while...)

    This is for both a Unix/Linux system or Windows.

    Thanks in advance.

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Apr 2009
    Rep Power
    Yes it is possible.

    So, now you should start working on writing the script and when you get stuck, post your code and a specific question.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Paris area, France
    Rep Power
    As a simple starting point, you could do something like this:

    Perl Code:
    while (1) {
         my @files = glob ("<directory>/*.<extension>");
         rename_files(@files) if defined @files;
         sleep 1; # waits 1 second before looping again.

    You just have to write the rename_files() function, which needs to iterate over the filenames and rename them one by one.

IMN logo majestic logo threadwatch logo seochat tools logo