Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 451957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:01:29+00:00 2026-05-12T22:01:29+00:00

#!/bin/sh #My script echo Are you sure you want to reorganize your files? echo

  • 0
#!/bin/sh
#My script

echo "Are you sure you want to reorganize your files?"
echo "Type y or Y to continue. Anything else will stop the process"
read response

if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
  mkdir video
  mkdir audio
  mkdir text
  mv -v *.txt text >> log.txt
  mv -v *.wmv video >> log.txt
  mv -v *.mov video >> log.txt
  mv -v *.mpg video >> log.txt
  mv -v *.mp3 audio >> log.txt
  mv -v *.wma audio >> log.txt


  echo "Yay, it worked!"
else
echo "Nothing happened."
fi

I wrote the script above to organize files into subfolders. For instance the music files will go into an audio folder. Now I would like to take a step further and make it more global.I would like to allow the script to accept a command line argument, which is the folder that contains the unorganized files. This should allow the script to be located and run from anywhere in the file system, and accept any folder of unorganized files.

Example:

organizefiles.sh mystuff/media // subfolders would go inside “media”

the folder media contains all of the media files.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:01:29+00:00Added an answer on May 12, 2026 at 10:01 pm

    A portion of your script could use the first positional parameter like this:

    if [ -d $1 ]
    then
        mkdir video
        mkdir audio
        mkdir text
        mv -v $1/*.txt text >> log.txt
        mv -v $1/*.wmv video >> log.txt
        mv -v $1/*.mov video >> log.txt
        mv -v $1/*.mpg video >> log.txt
        mv -v $1/*.mp3 audio >> log.txt
        mv -v $1/*.wma audio >> log.txt
    else
        echo "The destination directory does not exist"
        exit 1
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/bin/bash echo SCRIPT: $0 echo Enter Customer Order Ref (e.g. 100018) read P_CUST_ORDER_REF echo
Here's my batch script: @echo off cls set SOURCE=svn://vcrep/UXP/ercpac/trunk/ set SVN=C:\Program Files\TortoiseSVN\bin %SVN%\TortoiseProc.exe /command:update
Linux bash script: #!/bin/bash function Print() { echo $1 } var=* Print $var Execution
I have a script that looks like this #!/bin/bash function something() { echo hello
For testing purposes I have this shell script #!/bin/bash echo $$ find / >/dev/null
Not sure why the last line does not cut the from the script: #!/bin/bash
I have a bash script that looks like the following: #!/bin/bash FILES=public_html/*.php # */
I have this script called test.sh: #!/bin/bash STR = Hello World echo $STR when
My shell script is as shown below: #!/bin/bash # Make sure only root can
Say I have 2 scripts test1.sh #!/bin/sh . ./test2.sh foo test2.sh #!/bin/sh foo(){ echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.