Copying all files in subdirectories into another directory

In a previous post about Exporting from Endnote to Zotero, I wanted to find out how to copy all the files in the subdirectories into a separate directory without the subdirectories

Instead of having:


– .pdf

Directory 2

– .pdf

I wanted to have:


– .pdf1

– .pdf2


A little search on Google led me to a nice batch script (Thank you StackOverflow!. To run it, go into the PDF directory where Zotero or Endnote for that matter keep their files.

Notepad Treecopy.bat

Type the following:

@echo off
if %1’==’ goto usage
if %2’==’ goto usage
if %3’==’ goto usage
for /D %%F in (%1\*) do xcopy %%F\%2 %3 /D /Y
for /D %%F in (%1\*.) do call TreeCopy %%F %2 %3
goto end
@echo Usage: TreeCopy [Source folder] [Search pattern] [Destination folder]
@echo Example: TreeCopy C:\Users\Marianne\Dropbox\Library\CBHR.Data\PDF *.pdf C:\Users\Marianne\Dropbox\Library\CBHR.Data\exports

Go back to your command prompt, type Treecopy [the full path of source directory] *.pdf [full path of target directory]

That’s it! Brilliant!

Exporting from Endnote TO Zotero with attachments

This post will hopefully help people who are trying to export from Endnote into Zotero with attachments. I found it difficult to get the answer that I needed in order to import my Endnote library into Zotero and not lose all my .pdfs.

The first part of the instructions from are partly complete, and with some nuggets from here ( They leave out a piece of instructions that’s really important, which is mapping the path to where Endnote is storing its from as a full Windows path.

Ok. here goes step by step:

First part is from the Endnote site, again, from here:

Exporting EndNote Records

  1. If you wish to export a subset of your EndNote library, select the entries you wish to export.
  2. Now, go to the File menu > Export. A dialog box will pop up asking you where to save the export file.
  3. Navigate to your EndNote data directory (typically, My Documents\endnote.Data). This directory contains a ‘PDF’ folder, but you should be sure to select the data directory rather than any sub-directory. This is important: Zotero will look for file attachments in a directory relative to the RIS file you are exporting now. If this file is located in the wrong place during import into Zotero, file attachments will not be imported.
  4. Select “Text File (*.txt)” in the “Save as type” dropbox. Select “RefMan (RIS) Export” in the “Output style” dropbox. If you wanted to export a subset of your library and had selected items to export, check the “Export Selected References” box. Otherwise, make sure it is unchecked.
  5. Click “Save”.
  6. You may close EndNote at this point.

The piece of instructions that’s missing goes after number 6.

  • 7. In Windows, go to the directory where you saved the .txt RIS file.
  • 8. Look at the address bar where you see the name of the directory. It should be in the format of C:\Users\some_path\another_path. (note: I usually don’t have spaces in my directory or file names. If you do, then I’m not really sure what you can do other than rename the directories that have spaces to something with _ instead.
  • 9. Click on that address bar, and copy (ctrl-c) to copy the entire address.
  • 10. Open Notepad. If you don’t know how to open it, go to your Windows Start icon, and where it says Search Programs and Files with the search field, type notepad.
  • 11. In Notepad, paste the address of the directory that you just copied. It should be again, in the format of C:\Users\some_path\another_path. Change all \ to to / and change the path to be in the form of: file:///C:/Users/some_path/some_path/Library/Yourlibrary.Data/PDF/ The end “/” is important, so make sure it’s there.
  • 12. Copy that path.
  • 13. Now, go back to the directory where you saved your exported RIS .txt file.
  • 14. Open it with notepad so that there are no weird formatting issues. So, no Wordpad or Word or anything.
  • 15. Replace all instances of internal-pdf:// with the path where your .pdf directory is. Let’s break that down:
  • a. Press ctrl-h to go into the search and replace. In the first box, write internal-pdf://
  • b. In the second box, type file:///C:/Users/some_path/some_path/Library/Yourlibrary.Data/PDF/ (this is the link that you copied from step 11)
  • 16. Click Replace
  • 17. Once it’s done replacing (You won’t get a confirmation, but you’ll know when it stops), Save the file File > Save.
  • 18. Now, go to Zotero, and follow the rest of the instructions from
  • If you are not importing into an empty library, we highly recommend making a backup of you Zotero data directory. This will avoid a lot of frustration if you do not like the way your library has transferred. In that event, simply restore your library from the backup.
  • You should also temporarily disable automatic sync (if enabled) via Preferences → Sync → uncheck “Sync automatically”. Once you are satisfied with the way your references transferred, perform a manual sync (green circular arrow at the top right of the Zotero pane) and then re-enable automatic sync.
  • In Zotero, go to the Gear menu and select “Import…” A dialog box will appear asking you to select the file to import. Navigate to the location where you exported your EndNote library (if you followed the above instructions, this should be My Documents\endnote.Data) and select the RIS file. Note that the actual file extension may be ”.txt” instead of ”.ris”. Click Open.
  • The EndNote library will be imported into a separate collection. You may remove the collection (right-click > Remove Collection…) without deleting the imported references (they will be moved to the root of your library).

If it worked, you will see all your citations, plus a blue dot at the end of each source that has an attached .pdf.

Double click on the button, and Zotero will automatically open your .pdfs.

I hope this worked. Good luck!

SOLVED: Now all I need to figure out is how to make it so that all my .pdfs are in ONE directory rather than individual directories. If anyone knows, please leave a comment!

Go here for the solution: here. Great!