Results 1 to 5 of 5
Hi All,
I am currently using Ubuntu 9.10, and very much liked it.
However, I had used Windows earlier, which used to crash very frequently. So I had to many ...
- 12-02-2009 #1Just Joined!
- Join Date
- Dec 2007
- Posts
- 32
Sort Out Files based on File Type.
Hi All,
I am currently using Ubuntu 9.10, and very much liked it.
However, I had used Windows earlier, which used to crash very frequently. So I had to many files over and over again. These has now accumulated to more than 30 GB.
Now I want to sort files according to their file types. Like all *.doc file in "Word Files" Folder, and *.xls to "Excel Files" etc. I need the Command line for this, is it possible to do like this..
"for i in *.doc;cp "$i" "/word/$i";done"
Open to any other suggestions.
Also I need to compare files and if they are the same files (to be Checked with Content not Name), delete the older version, for this any utility/Tools/Programs availble
Thanks,
Harish.A
- 12-02-2009 #2Just Joined!
- Join Date
- Aug 2005
- Posts
- 65
to search in the directory and the subdirectories
this will move the files in a location u choose but it will override the files according to names without comparing the content .Code:find . -name "*.doc" -exec mv {} /path/to/doc/files
u can add to mv , mv -i , to make it interactive
for comparing , after moving the files in its folder u can use this
it looks working , try it with cautionCode:for i in * do for j in * do diff $i $j && [ $i != $j ] && rm $i done done
- 12-02-2009 #3
remember when using caution it is very easy to just add an 'echo' to your commands to see what would happen. Then if you like the out put remove the echo and run again.
it looks working , try it with caution
good? then runCode:echo rm *files_I_think_would_match*
Code:rm *files_I_think_would_match*
- 12-02-2009 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
You might find this useful:
see man fdupes for details, and write a few test scripts to see how it works.Code:fdupes - finds duplicate files in a given set of directories
I think I would use fdupes before copying the files by content. In Windows the suffix (.doc, .xls, etc) determines the file content. Not so in *nix where the suffix may mean something to other programs (e.g. file.c means something to the c compiler), but not to every utility in general. There is:
to help you with identification of content; see man file, and again I suggest getting comfortable by writing a few test scripts.Code:file - determine file type
The advice from mehorter is very good to avoid calamities, and a good backup is the final guard against human error, as well as against equipment failure.
Best wishes ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 12-03-2009 #5Just Joined!
- Join Date
- Dec 2007
- Posts
- 32
Hi,
Thanks for the suggestions, I will try it out.


Reply With Quote
