• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

OT - A little code help please

MoFunk

Diamond Member
Howdy all! Here is my problem. I need to be able to have some kind of script look on a CD with many folders and subdirectories and take every .pdf file it finds and copy it to a local folder. Can that be done?

Thanks in advance for any help you can offer.
 
find /cdrom -name "*.pdf" -exec cp {} ~/documents \;

😛

Works on most unix and unix0like systems, and may work under cygwin.
 
Hmm, looks like n0c wasn't very bashful about showing off his UNIX knowledge. 😀
Originally posted by: RemyCanad
I am sure that can be done. What OS does it need to run on?
Probably Windows. In which case MoFunk should look into Cygwin... it's so much better than the regular Windows tools for shell prompt stuff.
 
Originally posted by: jliechty
Hmm, looks like n0c wasn't very bashful about showing off his UNIX knowledge. 😀

First, I never use BASH out of choice, but good pun. And second, it took me 3 weeks to get that working correctly, I'm going to show it off. 😛
😀
 
Originally posted by: n0cmonkey
Originally posted by: jliechty
Hmm, looks like n0c wasn't very bashful about showing off his UNIX knowledge. 😀

First, I never use BASH out of choice, but good pun. And second, it took me 3 weeks to get that working correctly, I'm going to show it off. 😛
😀

noob 😛

...oh wait....i don't even know how to install *nix os's 🙁 😱
 
Well... if you want to preserve the directory structure that the files are in on the CD (which may be necessary if you have duplicate file names across directories), the easiest way in Windows is...

xcopy d:\*.pdf localdir /s

That will work and will recurse through the whole directory structure... Then if you want a quick list...

dir localdir/*.pdf /s /b > localdir/filelist.txt

should do the trick... why reinvent the wheel? 🙂
 
Originally posted by: n0cmonkey
First, I never use BASH out of choice...
Well, when I started with the UNIX-like OSes, I used Linux, so BASH was my first experience with shells. Ever since then, I've never bothered to try anything else. What's your favorite shell, anyway, and do you have some reasons why you like it better than the (standard, on most Linux, it seems) BASH?
 
Why not just use the windows search feature, take the results selcect all, copy to location?

Assuming this is windows and you don't want the directory structure.
 
Originally posted by: TofBnT
Why not just use the windows search feature, take the results selcect all, copy to location?

Assuming this is windows and you don't want the directory structure.


Can you script that? 🙂
 
Originally posted by: jliechty
Originally posted by: n0cmonkey
First, I never use BASH out of choice...
Well, when I started with the UNIX-like OSes, I used Linux, so BASH was my first experience with shells. Ever since then, I've never bothered to try anything else. What's your favorite shell, anyway, and do you have some reasons why you like it better than the (standard, on most Linux, it seems) BASH?

I typically use pdksh. It's more bourne and korn compatible. ksh will be found on most Unixes and Unix-like systems. bash is find for Linux users, but I use a variety of systems. 😉
 
Thanks for the replies all. This will be for Win2K Pro. I always forget to mention the OS! What is happening is that one of the hospitals my company bills for is going to start scanning patient charts and sending them to us on cdrom. The cdrom contains a folder called patient info, then under that each patient name has a folder, then under each patient folder there are 2 more folders. 1 with the .pdf file I need to print, the other is stuff I do not need and it is not pdf. I have had numerous calls with them to try and find a better way to no avail, this is what I have to work with. Now the people that are going to be doing this work are not very savy, so I need to make this as easy as I can. This is why I want to script something. I tried to do this with a bat file, but I am not very educated in scripting. Is there some vb script I can do?
 
Still need more info... if the files you need always have the same name (eg chart.pdf), then you can't just copy them all into one directory because they will all have the same name and you'll end up with just one file. The xcopy command above will copy them from the CD to your local drive and create the directories that the files live in on youre local drive. The dir command will leave you with a file that has the locations of all the pdfs. I'm only guessing here, but I figure the adobe reader must allow you to call it from a command line with command line parameters to just print the document out (could be wrong here, though...). A quick VB program to open the text file, read it line by line and call the reader would do the trick 🙂

Geoff
 
Found it.... one DOS command will print them all out 🙂

for /R %f in (*.pdf) do <path-to-acrobat-reader-here>\AcroRd32.exe /t "%f" printername drivername portname

The /R parameter on the for command means recurse through all the subdirectories. Try this from your command line in the root directory:

for /R %f in (*.txt) do @dir "%f" /b

But, you need to be in the directory of the drive you want to execute this from, so in your batch file, you'd need to do a couple of commands to move to the cdrom, and then move to the root dir of the cdrom.

The /t command line option initiates Acrobat Reader, prints a file while suppressing the Acrobat print dialog box, then terminates Reader. It takes 4 command line parameters : path, printername, drivername, and portname (all strings).

printername - The name of your printer.
drivername - Your printer driver's name. Whatever appears in the Driver Used box when you view your printer's properties.
portname - The printer's port. portname cannot contain any "/" characters; if it does, output is routed to the default port for that printer.

Since this will be in a batch file, you need %%f instead of %f 🙂

Geoff
 
Just a bit more info on the acrord32 command:

To print an Adobe Portable Document Format (PDF) file, you need Adobe Acrobat.

The syntax for printing a .PDF document from the command-line is:

PathToAcrobat.exe /t Filename Printer PrintDriver PrinterPort

where:

PathToAcrobat.exe is the path to Acrobat.exe or Acrord32.exe.
/t prints the document and is supposed to terminate.
Filename is the path to the .PDF document you wish to print.
Printer is the name of the printer you want the document to print on.
PrinterDriver from the printer's Properties page.
PrinterPort The printer's port, which cannot contain any / characters.
Example:

"C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe" /t "C:\Saved\Protect_Your_PC.pdf" \\JSI001\HP2250 "HP Business Inkjet 2250 (PCL5C)" LPT1:
 
Back
Top