-3

I'm trying to write a script that will put files with different extensions into their specified directories .

In the directory are files of various types, i want to arrange the files on individual directories under their type. There are three distinct types of files:

  1. Text documents - files with extensions. Doc,. Txt,. Pdf, ...
  2. multimedia files - with the extensions. Mpg,. Avi,. Mp3 ...
  3. graphics files - with the extensions. Jpg,. Gif,. Png ...
  4. All other files

Files types 1-3 to move into individual directories and files of other types have to move in directories with names corresponding to the extension (you can bring them to uppercase - BAK, CPP ,...).

i want the script to run with the following parameters:

  1. -m path - if specified, the multimedia files will be moved to the directory PATH
  2. -d PATH - specifies the path where you have to move your documents
  3. -l indicates that when the file names should lead to lower case
  4. -x indicates that they move to lower case file extension

any ideas?? I am a newbie and I'm trying to learn bash scripting so I thought of this question

Taryn
  • 242,637
  • 56
  • 362
  • 405
  • For what it's worth, this is a good program to get your feet wet and get familiar with bash scripting. – Dan Fego Dec 09 '11 at 15:09
  • Find some tutorials on bash scripting which should get you to the point of tackling this. Try: http://stackoverflow.com/questions/1600139/looking-for-recommendations-on-a-good-beginners-bash-tutorial to start with. – xan Dec 09 '11 at 15:33

1 Answers1

3

This should be easy. Learn how mv works, how to manipulate string variables in bash (aka parameter expansion), and how to handle arguments. You can use tr to handle lower- and upper-casing.

choroba
  • 231,213
  • 25
  • 204
  • 289
  • he? should learn about getopt/getopts (and the crucial differences between the two) as well as looping structures and case statements ;-) Good luck to all. – shellter Dec 09 '11 at 15:04