Linux Question (not HE related)

This is not a HE related question.

I have a synology NAS with the ability to run scripts. I'm looking to automatically move files from one directory to another, for backup to cloud. I'm nearly there, but cant seem to get the final piece into place. Any help appreciated.

This is my script:

#!/bin/sh
mv "/volume1/source/"*.jpg "/volume1/destination/"

The error returned is:
mv: target '/volume1/destination/\r' is not a directory"

Why is it placing a \r after the path?? For some reason, it's including the \r as part of the path, as seen by the single quotation makrs. Nothing is being moved, obviously.

mv /volume1/source/*.jpg /volume1/destination/

No "

That moves all jpg files to the destination

That's what I want - moving all files to the destination.

mv /volume1/source/*.jpg /volume1/destination/

Then that's the command.

Thanks, I'll give that a go, and no doubt come back with a new error!

LOL you won't.

MV(1) User Commands MV(1)

NAME
mv - move (rename) files

SYNOPSIS
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...

DESCRIPTION
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

http://man7.org/linux/man-pages/man1/mv.1p.html

Got exactly the same error:
mv: target '/volume1/destination/\r' is not a directory"

Umm what is the path you want to move from and the path to move to ?

Paths MUST be already created

The directory exists, by the way.

That error tells me 1 thing
/volume1/destination/ is not a directory

1 Like

Appreciate @anon61068208 working with me thru PM. Got it working.

It was creating the script in windows text editor, adding in some hidden characters (\r).

Thanks, thanks, thanks!

1 Like

Just a suggestion. Rsync might be a better choice than move. It's got a steep learning curve, but you can do copy->validate->delete to ensure things are moved and present.

Takes some google fu to get started though.

S.

2 Likes

Nothing wrong using mv in this case. It's not like he was moving a partition and needed to keep permissions and ownership.

Oh agreed. I just think rsync might be a better choice if he does this often.

But, as you said, mv will certainly do the job.

S.