Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 2nd May 2009, 23:52
PatrickMc PatrickMc is offline
Junior Member
 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default How to move text files to parent folder

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.

Quote:
Start with folder folder1, find files *.txt in the folder and subfolders, move all .txt files back one level up (into parent folder).
Here is the script.

Code:
var str list ; lf -rn "*.txt" "folder1" > $list
while ($list <> "")
do
    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."
    else
        system move ("\""+$file+"\"") ("\""+$parent+"\"")
    endif
done
This script is in biterscripting ( http://www.biterscripting.com/install.html ) .


Patrick
Reply With Quote
The Following User Says Thank You to PatrickMc For This Useful Post:
falko (3rd May 2009)
Sponsored Links
  #2  
Old 3rd May 2009, 18:49
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 Posts
Default

Quote:
Originally Posted by PatrickMc View Post
I can't post an answer there since when I click REPLY, it shows me a blank screen.
Hi Patrick,

can you tell me which browser and browser version you're using, and which OS? Does your browser accept cookies from HowtoForge?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 8th May 2009, 20:00
PatrickMc PatrickMc is offline
Junior Member
 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default biterscripting mv (system) command

nicephotog:

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.)

falko:

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.

Patrick
Reply With Quote
  #4  
Old 15th July 2009, 06:38
mdjzh mdjzh is offline
Junior Member
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

I like the idea, cool!
__________________
no better runescape accounts, just best runescape accounts!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ffmpeg Video support for ubuntu 7.10 [suphp-ispconfig] amaurib Installation/Configuration 13 16th February 2010 18:26
The system is currently updating the configuration files. warlock General 8 21st February 2009 19:15
Symbolic link to all files of a folder hhhhhh Installation/Configuration 0 3rd February 2009 03:32
Move junk mail to a folder instead of deleting grant Tips/Tricks/Mods 20 23rd October 2008 00:09
How to keep in RAM a number of text files? calande Server Operation 2 7th January 2008 18:17


All times are GMT +2. The time now is 04:03.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.