Command Line Copy

EPicture of Linux Terminal Window with Codevery year we digitize The Wilmington Town Crier papers. We send ’em off and get pdfs
on a USB drive (as well as the originals) returned. From there I load them into a Drupal website using Solr and Tika for indexing (a setup I don’t recommend). But in order to do so, the pdfs must all be in the same directory.

Well, it turned out that the 2016 batch of papers put each issue in its own folder. Since I didn’t want to have to manually move all the files, I searched for a way to do it all at once. And I found it.

1.) Open a command prompt (start > run > cmd)

2.) Change directories to the USB drive

3.) Type the following code, replacing “target” with the folder you wish to drop all the files into.

for /r %f in (*) do @copy "%f" target

For example, here was my code:

G:\2016>for /r %f in (*.pdf) do @copy “%f” G:\2016

You’ll notice I only wanted to move the pdfs. That’s because there were other files (.jp2, txt, tif) in those folders and I didn’t care about them. If you want to move everything just leave it as (*).

And that’s it!

Since I want to give credit where it’s due, here’s where I got the line of code:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s