-1

This is my script I am trying to rename the files in folder.

rename1.sh
----------
#!/bin/bash
cd /home/lanein1/WestonIN7pm/"$(date +%Y-%m-%d)" && rename s/WestonIN/WestonIN7pm/ *.jpg
cd /home/lanein1/WestonOUT7pm/"$(date +%Y-%m-%d)" && rename s/WestonOUT/WestonOUT7pm/ *.jpg

This is the error I get :

can't cd to /home/lanein1/scripts/rename1.sh

I don't understand why am I getting this error

CRON ENTRY :

29 12 * * * cd /home/lanein1/scripts/rename1.sh >> /home/lanein1/scripts/rename2.log 2>&1

closed as off-topic by roaima, Archemar, dhag, Anthon, Jenny D Sep 4 '15 at 17:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – roaima, Archemar, dhag, Anthon, Jenny D
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    That error message doesn't correspond with the code you've provided. How exactly are you calling this script? (Please edit your question. Don't answer here in comments.) – roaima Sep 4 '15 at 11:42
  • the script is stored in /home/lanein1/scripts/reanme1.sh. Calling it through cron 29 12 * * * cd /home/lanein1/scripts/rename1.sh >> /home/lanein1/scripts/rename2.log 2>&1 – preethi Sep 4 '15 at 11:42
  • Is /home/lanein1/scripts/rename1.sh a directory? – Cyrus Sep 4 '15 at 17:08
8

You're asking to change directory to the script:

cd /home/lanein1/scripts/rename1.sh >> /home/lanein1/scripts/rename2.log 2>&1

Perhaps you meant to run it:

/home/lanein1/scripts/rename1.sh >> /home/lanein1/scripts/rename2.log 2>&1

Not the answer you're looking for? Browse other questions tagged or ask your own question.