Hallo
I have a lot of PDF documents. I diceded to sort all of them. First off all I did was searching for duplicate files with fdupes. I delete all duplicated files, and now I want to move all PDF files on one location. Off course I want to use CLI. And thats why I need a help.
I have tried so:
find ~/Desktop/1-9-5 -name ‘*.pdf’ | mv /home/najkarika/Desktop/345/
but something was wrong.
Please help me.
Thanks
That doesn’t work. My not try:
# cd ~/Desktop/1-9-5
# mv *.pdf /home/najkarika/Desktop/345/
I hope that works, it’s not pretty though.
Something more pretty is this:
# find ./ -name '*.pdf' -exec mv {} /home/najkarika/Desktop/345/
You cannot use pipe with find and mv command. Move command doesn’t work with stdin. You need to use exec here in this fashion:
find ~/Desktop/1-9-5 -name ‘*.pdf’ -exec mv {} /home/najkarika/Desktop/345/ \;
Thanks for your answers. But it didnt help. Only with:
find ~/Desktop/1-9-5 -name “*.pdf” -exec mv /home/najkarika/Desktop/345/ {} ;
Became I answer: mv: cannot overwrite non-directory
@Abhishek made a typo. The mv arguments should be in source, destination order:
find ~/Desktop/1-9-5 -name '*.pdf' -exec mv {} /home/najkarika/Desktop/345/ \;
The -exec
option tells to the find
command to execute another command on each matching file. \;
marks the end of that external command. And {} is a placeholder for the name of the matching file currently examined by find
.
EDIT: take care of not mistakenly use the backtick ` instead of a single quote ’
EDIT2: I took the liberty of changing the thread title. Don’t hesitate to change it back if you disagree.
That’s it. Perfect. Thank you.
All PDFs are in one Folder.
And the name for thread is also great.
Thanks for spotting that. I was in a hurry
When i using find and -exec. Hope you got some more idea or so…
find /home -type f -name "*.txt" -exec cp {} . \;
find all txt and copy in current dir
find /home -type f -name "*.txt" -exec rm {} \;
find all txt and delete
find / -type f -perm 0777 -print -exec chmod 644{} \;
find all of 777 perm and chmod to 644
And ofc. I occasional use and tar command when i back-up something.
like find all *.conf files and tar them. u can use -p option in tar to save permission
…