LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-17-2010, 10:14 AM   #1
johnychemist
LQ Newbie
 
Registered: Oct 2010
Posts: 10

Rep: Reputation: 0
Linux Automatic File Movers


Hi Guys and Girls

I have been using linux now for a very short time, and the more I use the more I like, however some things are just too far beyond me to figure out, like scripts, etc... So I do prefer to use GUI apps wherever possible, and I'm using SUSE 11.3

I'm looking for a way to automatically manage a folder I use for auto downloads. I'd like to be able to at least:

Move files to another directory based on either the files age i.e. 2 weeks, or the remaining disk space on the disk to initiate a move function. (Preferably the 1st and then the 2nd if necessary)

And then a function to lookup similar folder names and put the file into that folder if it exists. (More complex I know, I'm not holding my breath)

I've been looking for something like this for some time now and haven't been able to find anything via google, hopefully someone with some experience could be so kind as to help me with this?

Thanks,
 
Old 10-17-2010, 01:05 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,889

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
Welcome to LQ.

First, a bit of advice. When searching the web for Linux related solutions to problems, use www.google.com/linux, which filters 99% or more of unrelated hits (similar search filters for microsoft and mac also exist). You are more likely to find solutions that way.

Second, point your browser at the linux search link above, and search for "automatically move files".

The only tool that turns up repeatedly is fsniper. It is a script which you edit to suit your needs. Instructions for editing the script are in the doc file. Installation instructions are in the INSTALL file. Oh, I forgot to mention that it's a .tar.gz file to be compiled. There are two dependencies mentioned in the INSTALL file. One of them is included with the tarball; the other may already be installed on your system.

Give it a try. If you have trouble with the scripting, come back with samples of the code that are giving you trouble. Copies of the sample code in the supplied doc file might also be useful.

The coders around here should be able to help you.
 
Old 10-17-2010, 01:41 PM   #3
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
Hey. Good thing you're liking GNU/linux. Learning basic commands and some shell scripting will help you for lots and lots of different tasks, and they're much fun to learn^^.

A script as the one you're looking for doesn't sound too hard, but you'll have to read some man pages or browse the web some too.
"find file weeks old" yielded this which kind of gives you a hint of how to start.
First, read a bit the man page of the "find" command while reading that example.
So, a good start might be...
Code:
cd /home/username/my_temp_dir
find . -type f -daystart -ctime +7 -exec mv {} some_other_dir/ \;
Instead of deleting the files, as in the example, you'd be moving them to some_other_dir.

For the second part, you would need a basic "if" sentence (read about bash scripting).
Code:
df |grep home|awk '{print $4}'
This command would return your available(not used) disk size in Kilobytes.
So you could say
Code:
if [ 100000 -gt $(df |grep home|awk '{print $4}') ] ; then
#translation= "if 100000K is more than my disk's free space, then..."
# or simpler "if I have less than 100000K available, then..."
    move_old_files_function_here
fi
Do please read all command's man pages, at least so you understand what you're doing (awk is kinda huge, but basically it's priting its input's 4th field).
After finishing this (and ordering all under different files, or one single file with separated functions), you can use cron or crontab to schedule the script to run as often as you want.

For the third part you'd have to know about regular expressions and depending on the method you use may not be so simple to do...
 
Old 10-17-2010, 06:10 PM   #4
johnychemist
LQ Newbie
 
Registered: Oct 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Ok thanks

Ok thanks Guys, much appreciated - Will take a dive at this in a few days and post the results.

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic updating of file on a different machine (server) when user saves a file resetreset Linux - Software 6 03-02-2010 12:32 PM
LXer: 12 open source movers and shakers who Twitter LXer Syndicated Linux News 0 01-24-2009 08:40 AM
LXer: Open Letter to the movers & shakers in Massachusetts (Governor Romney, Secretary Galvin, Senator Hart, et al) LXer Syndicated Linux News 0 12-27-2005 01:46 AM
LXer: Open Letter to the movers & shakers in Massachusetts (Governor Romney, Secretary Galvin, Senator Hart, et al) LXer Syndicated Linux News 0 12-24-2005 08:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration