Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash mkdir and cp error on variable path "cannot create directory : No such file or directory"

Tags:

bash

mkdir

cp

I'm trying to automate copying the content from a variable path (my camera) into a partially-user-defined path (desktop+date+event). The problem is that mkdir and cp complain saying that the directory cannot be created, but I don't understand why despite having DuckDuckGo'd for over an hour. What am I doing wrong?

echo -n "Enter event name and press [ENTER]: "
read event
sleep 0

day=`date +%Y-%m-%d`
month=`date +%Y-%m`
media="/media/F009-64A5"

source="${media}/PRIVATE/AVCHD/BDMV/STREAM/*"
target="/home/kv/Desktop/$month/$day"\_"$event"

mkdir $target
cp -pr $source $target
like image 576
octosquidopus Avatar asked Aug 18 '11 23:08

octosquidopus


1 Answers

mkdir -p $target will create the path with all necessary subpaths.

like image 58
Lars Avatar answered Sep 20 '22 23:09

Lars