Move files to variable directory

Im trying to move my files to a variable folder i've just created.

Step 1 is working fine.

mkdir /sdcard/DCIM/Photos/`date +%Y%m%d`

Step 2 is not working

mv /sdcard/DCIM/100ANDRO/*.jpg /sdcard/DCIM/Photos/`date +%Y%m%d`

What am i doing wrong?

From what you've posted I don't see anything odd. What O/S and shell are you using? What, if any, error messages are being written.

For what it is worth, when I create file and/or directory names using a command, I run the command once, and save the output in a variable using the contents for everything later. In your case, there shouldn't be any variable data in the output from date (as long as you didn't run command one at before midnight and the mv command after midnight), but it cannot hurt.

As an example:

targetd="/some/file/path/$(date "+%Y%m%d")"
if [[ ! -d $targetd ]]
then
   mkdir $targetd
fi
mv /source/path/*.jpg $targetd/

Thanks for your reply.

Unfortunately you're script doesn't work either, the folder will not be created in the first place.

I'm using Android. Any other options :slight_smile: ?