Question about move command

Is there a way to undo a move after running a command such as this:

find ./* -type f -name "*.pdf" -exec mv {} /new/dir \;

:confused:

No, there is no "undo".

Whether you have lost files depends on whether /new/dir existed as a directory and whether every filename.pdf had a unique name.

Back to backup I fear. Even if every filename was unique, you need to know where they came from.

Understood.

So is there some other way to "create" and undo option? Like have the command do a file list first, then for the undo, have it reference the file list and move the files back to the original directories?

you can make alias of the actual command.. like rm and mv.

create a file in home dir say .secure_mv

/home/anchal_khare->cat .secure_mv
cp $1 $1.bkp
mv $1 $2

now create and alias for mv in your shell profile ( say .bashrc for bash shell)

alias mv='~/.secure_mv'

now everytime you execute the mv command it will first create a copy of file.bkp before moving it.

note: this is just an idea.should not be used professionally.