How to move text files to parent folder

Discussion in 'Programming/Scripts' started by PatrickMc, May 2, 2009.

  1. PatrickMc

    PatrickMc New Member

    Someone had asked a scripting question about how to move all .txt files to their respective parent folders. I can't post an answer there since when I click REPLY, it shows me a blank screen.

    Anyway, here are the requirements.

    Here is the script.

    var str list ; lf -rn "*.txt" "folder1" > $list
    while ($list <> "")
        var str file ; lex "1" $list > $file
        # $file now has the full path of one file. Strip off the last instance of
        # /.../ . If that does not exist in full path, this file is at the top level.
        var str parent ; stex -r -p "]^/&/^" $file > $parent
        if ($parent=="")
            # There is no parent folder to copy this file to.
            echo $file " is already at the top-most level directory."
            system move ("\""+$file+"\"") ("\""+$parent+"\"")
    This script is in biterscripting ( ) .

  2. falko

    falko Super Moderator ISPConfig Developer

    Hi Patrick,

    can you tell me which browser and browser version you're using, and which OS? Does your browser accept cookies from HowtoForge?
  3. PatrickMc

    PatrickMc New Member

    biterscripting mv (system) command


    Thanks for your tip. But if you were to execute the mv command from the command prompt, you would have to do this folder by folder - first cd to a folder, then do mv. No ? (I guess the original poster was looking for a script to do all of that in just one command.)


    Thanks for your consideration. Actually, it (the blank screen) is not happening here. I am able to post a reply here. So, I guess that was only a temporary phenomenon.

  4. mdjzh

    mdjzh New Member

    I like the idea, cool!

Share This Page