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

  • Home
  • SEARCH
  • 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 668195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:00:47+00:00 2026-05-14T00:00:47+00:00

I am attempting to automate moving files from a folder to a new folder

  • 0

I am attempting to automate moving files from a folder to a new folder automatically every night using a bash script run from AppleScript on a schedule. I am attempting to write a bash script on Mac OSX, and it keeps failing. In short this is what I have (all my echos are for error checking):

#!/bin/bash
folder = "ABC"
useracct = 'test'
day = date "+%d"
month = date "+%B" 
year = date "+%Y"
folderToBeMoved = "/users/$useracct/Documents/Archive/Primetime.eyetv"
newfoldername = "/Volumes/Media/Network/$folder/$month$day$year"
ECHO "Network is $network" $network
ECHO "day is $day"
ECHO "Month is $month"
ECHO "YEAR is $year"
ECHO "source is $folderToBeMoved"
ECHO "dest is $newfoldername"
mkdir $newfoldername
cp -R $folderToBeMoved $newfoldername
if [-f $newfoldername/Primetime.eyetv];
    then rm $folderToBeMoved;
fi

Now my first problem is that I cannot set variables at all. Even literal ones where I just make it equal some literal. All my echos come out blank. I cannot grab the day, month, or year either,it comes out blank as well.

I get an error saying that -f is not found.

I get an error saying there is an unexpected end of file.

I made the file and did a chmod u+x scriptname.sh

I’m not sure why nothing is working at all. I am very new to this bash script on OSX, and only have experience with windows vbscript. Any help would be great, thanks!

  • 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-14T00:00:48+00:00Added an answer on May 14, 2026 at 12:00 am

    Assignment in bash scripts cannot have spaces around the = and you probably want your date commands enclosed in backticks $():

    #!/bin/bash
    folder="ABC"
    useracct='test'
    day=$(date "+%d")
    month=$(date "+%B")
    year=$(date "+%Y")
    folderToBeMoved="/users/$useracct/Documents/Archive/Primetime.eyetv"
    newfoldername="/Volumes/Media/Network/$folder/$month$day$year"
    ECHO "Network is $network" $network
    ECHO "day is $day"
    ECHO "Month is $month"
    ECHO "YEAR is $year"
    ECHO "source is $folderToBeMoved"
    ECHO "dest is $newfoldername"
    mkdir $newfoldername
    cp -R $folderToBeMoved $newfoldername
    if [-f $newfoldername/Primetime.eyetv]; then rm $folderToBeMoved; fi
    

    With the last three lines commented out, for me this outputs:

    Network is 
    day is 16
    Month is March
    YEAR is 2010
    source is /users/test/Documents/Archive/Primetime.eyetv
    dest is /Volumes/Media/Network/ABC/March162010
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to automate some legacy Delphi 5 builds with an MSBuild script,
I am attempting to pull some information from my tnsnames file using regex. I
I am currently working on a script that I am attempting to automate via
im attempting to do the django tutorial from the django website, and ive run
Attempting to print out a list of values from 2 different variables that are
Attempting to deploy a MOSS solution to a UAT server from dev server for
Scenario: Attempting to import many (>100), large(>1M recs) flat-files (csv). Problem: Many records are
When attempting to open a project from source control on a newly formatted pc,
I am attempting to automate the entry of data into form fields. The problem
I am attempting to drop and recreate a database from my CI setup. But

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.