How do you organise home with a script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do you organise home with a script?
# 1  
Old 08-04-2012
Java How do you organise home with a script?

Hi,

I am helping my dad with his computer and he has the messiest folder organisation imaginable.

Would it be possible to create a script which moves all images not in the Pictures folder to pictures, all documents not in Documents to Documents, videos to Videos etc?

But of course ignoring hidden directories as that would ruin settings!

From the home directory root because he sometimes saves files in the home root. And in folders in the Desktop.

Would it ignore links too? Like if I put links on his Desktop to Documents, Pictures etc I hope it wouldn't go through those because that would go on infinitely right?

I can't think of how to do it it seems quite complicated, but I think its probably simple compared to most of the questions you guys get Smilie

Just the basic structure I would like and I can add other file extensions myself if I find they are not being moved Smilie

This would be much appreciated thanks in advance!
# 2  
Old 08-04-2012
People like him are the sort of folks desktop search was invented for, sadly, because they can't be cured. Smilie If you move his files on him, he will never be able to find them again.

He should not have permissions to write to the home directory root, you can fix that. ls -ld /home please.
# 3  
Old 08-04-2012
Hehe I hope to try.

By root home directory I just meant his personal root home directory Smilie /home/username not /home. He saves things in username folder. His desktop has a whole new documents folder as well! I would never find anything on this computer!

I mentioned a script to organise to him and he seemed to like the idea, so I am hoping to try it anyway if anyone has any ideas Smilie

Code:
drwxr-xr-x 5 root root 4096 Aug  4 00:21 /home

# 4  
Old 08-04-2012
What operating system is this? A linux distro?
# 5  
Old 08-04-2012
Could start with something like this.

Code:
find ~/ -path '!' "/home/username/pictures' '!' -name '.*' -type f -name '*.[jJ][pP][gG]' |
while read FILE
do
        echo mv "$FILE" ~/pictures/
done

This User Gave Thanks to Corona688 For This Post:
# 6  
Old 08-04-2012
This is Linux Mint.

Thanks Corona that looks interesting, I seem to understand it too!

Do you need to repeat it for each extention?
*.[jJ][pP][gG] Or is that regex which can be made to include all picture types in the one line?

Would love to be able to come up with things like this so easily it seems fun and interesting Smilie Shame I don't have enough practical applications to warrant loads of study Smilie This is like the only script I have ever thought to use

I can't try this now because it is really late. Will let you know how I go tomorrow probably!
# 7  
Old 08-04-2012
It's not a regex, it's a glob. You can put a bunch of different types in like this:

Code:
find ~/  otheroptions '(' -name '*.[jJ][pP][gG]' -o '*.[pP][nN][gG]' -o '*.[gG][iI][fF] ')'

This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

UNIX script home work

plz can any one help to write the script of the output provided in the pdf. There are 2 tasks A and B. (5 Replies)
Discussion started by: mohdsadik90
5 Replies

2. UNIX for Beginners Questions & Answers

organise mailing lists in email client

mr macos please bare with me i couldnt find a place to post my issue and hence m posting it here How do you organise mailing lists in your email client? How do you guys organise your mailing lists? I'm having a few issues with my set up: When I subscribe to a mailing list I add a rule in the... (2 Replies)
Discussion started by: georgekhaidas
2 Replies

3. Shell Programming and Scripting

Script to report database home in unix

Hello: I am trying to build a ksh shell script which would summarize space occupied by "product" directory under /u*/app/oracle and summarize and report the total size occupied by it in one server. Environment is this... HP UNIX 11i Korn Shell some thing like ... (1 Reply)
Discussion started by: Sam1974
1 Replies

4. Shell Programming and Scripting

Prompt home made script

Hi I made a script called mydf which puts out the amount of storage space left on the file system; df | head -2 | tail -1 | tr -s " " | cut -d" " -f4 But I would like to run it with every new prompt, so you get something like; user@5518748~$ in your prompt (5518748 being the mydf output). Its... (2 Replies)
Discussion started by: mdop
2 Replies

5. Shell Programming and Scripting

cp -p /home/* home/exp/*.date not working please help

:( ---------- Post updated at 01:51 AM ---------- Previous update was at 01:50 AM ---------- Not working ---------- Post updated at 02:04 AM ---------- Previous update was at 01:51 AM ---------- cp -p /home/* home/exp/*.`date` i am using this (4 Replies)
Discussion started by: rishiraaz
4 Replies

6. Shell Programming and Scripting

script to check for a directory in /home for all users

Following on from this post: https://www.unix.com/shell-programming-scripting/150201-simple-script-mount-folder-all-users-home.html and getting told off for bumping the thread:( Please could someone help me with a short script to check is a certain directory is present in /home for all users... (8 Replies)
Discussion started by: barrydocks
8 Replies

7. Shell Programming and Scripting

how to organise a file

I have a file with only one record and the file size would be around 80 MB. Is there a way, where I can read and write this to a file with only 80bytes in each row (3 Replies)
Discussion started by: Muthuraj K
3 Replies

8. UNIX for Dummies Questions & Answers

why doesn't this script work on my home computer?

Now it could be as simple as at work I use tsch, and at home it is bash. Warning, first post and I am a complete newbie to unix. At work, I use a simple script for updating a window when I am watching to see how a render is doing... while 1 echo --------------------------- echo ls -lrth... (1 Reply)
Discussion started by: iStealMusic
1 Replies

9. Solaris

Accessing the home directory in shell script

How can I access home directory in a shell script. I am writing a script which will delete the log files in each of the user's directory Krishan (1 Reply)
Discussion started by: krishan
1 Replies

10. Programming

How I organise my project in unix environment.

I want develop a library in solaris, I want to know where the source and header files that I coded should place at. Thank you in advance for your comment. (0 Replies)
Discussion started by: nianzhe
0 Replies
Login or Register to Ask a Question