Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 2372  / 1 Year ago, wed, december 21, 2022, 2:07:07

I have many files in my external harddrive, so I want to automatically tell the computer to sort all my files into folders, by their size, extension, name and other variables. Is there any program that will allow me to perform these tasks. Please teach me how to install it too.


More From » files

 Answers
6

If you're OK to use bash commands, you should look the man page for the find command Manpage icon.



find . -name *.txt -size +599k -exec mv {} bigTextFolder ;


With this line, you can move all .txt files bigger or equal than 600KB into the bigTextFolder folder. You can find a lot of documentation about find on the net (Beginner Linux Guide) and the list of all tests available in the man page (first link).



To understand the command, look arguments:




  • . is the directory where find will look for file. You can replace that by the path of your HDD.

  • -name *.txt is the name filter. It can use wildcards(*) if you escape them with . You can read this like "Find all the file with a name ended by .txt". Replace that by the pattern you're looking for:


    • All file beginning by a: find . -name a*

    • The file aba.txt: find . -name aba.txt


  • -size +599k is the size filter. Here you say "Find all the file with a size strictly superior too 599KB". Change 599 to the size you want, and k is just the unit.

  • -exec allows to execute another command once a file is found. So here, for each file found, we do mv fileFounded targetFolder. The {} will be replace by your result. This part has to end with ;.



Keep in mind that you have a lot of other filters: type, date, owner, permissions,...


[#34391] Thursday, December 22, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
coffekne

Total Points: 114
Total Questions: 122
Total Answers: 126

Location: Mauritania
Member since Sun, Oct 17, 2021
3 Years ago
;