How to synchronize all PDFs from one directory with Dropbox

dropboxfindlnrsync

I want to synchronize all the PDFs from one directory (my Zotero library) to Dropbox. Finally, I want to have a list of all the PDFs, not the directory names.

I successfully synchronized all my PDFs with the following command:

rsync -az --include="*/" --include="*.pdf" --exclude="*" \ 
--prune-empty-dirs /zotero /dropbox

I think I can easily set up a cron job to redo that task every day, but haven't tried that yet.

But now my folder on Dropbox still has all the directories with the PDFs in it (e.g. 6NVTACJH > xyz.pdf)

My problem:
I would love to only have all the pdfs listed in one directory. Following an advice from the web, I tried to find all pdfs and create a hardlink.

But this command does not work yet.

ln $( find -name="*.pdf" -type f - links 1 ) /dropbox

Can you please help me with that last command?

Best Answer

I suggest using find -exec rather than command substitution cos it handles filenames well.

If you are trying to copy all pdf files into one single level /dropbox dir?

find /zotero -type f -name '*.pdf' -exec cp {} /dropbox/ \;

If you want links:

find /zotero -type f -name '*.pdf' -exec ln {} /dropbox/ \;

Update: You can use rsync on single file, just replace cp/ln with rsync(This will be slow):

find /zotero -type f -name '*.pdf' -exec rsync -avz {} /dropbox/ \;

Another choice is tar, which also provide updating by access time function.

I have to ask why you need to do this, you use Dropbox's limited version control? Or are you using Dropbox to share the files on-the-fly?

For those I need versioning and alpha-updating I personally have git or bazaar repository resides in Dropbox folder, do commit in my local dir, then push to Dropbox folder, simply faster than any hoster.