Shell command issues

Hi,
how to fill in a previously created file with the “touch” command ? (like with text: Grunt!)
and how to write the correct syntax for whitespaces in quoted paths ˜/ ˜ so that the finder accepts the imput ?
finally, exists a way to convert pdf’s in normal text files?

When you say whitespace in paths, do you mean “Users/My\ Name/Downloads/A\ Folder” instead of “Users/My Name/Downloads/A Folder”? The former is how to enter it in a do shell script command, or directly into Terminal.

There is a Mac pdftotext command line tool on this web page (lower right).

http://www.bluem.net/downloads/plain-clip-plug-en/

Yeah,
both informations matches what i need, thanks guys. Rests only the one issue: how to fill in files created with touch (with text data in my case)

Hm, i’m not able to figure out how to write the right syntax of the shell program…

set ff to POSIX path of (path to documents folder)
set the_file to ff & "Catalog/User Guides/PROCAD24 copia.pdf"
display dialog the_file

do shell script ("/usr/local/bin/pdftotext " & "-raw " & the_file as text)

--"Users/My\ Name/Downloads/A\ Folder" < my Script editor (Leopard, vs.2.2.1) doesn't accept this form, perhaps a language issue?
--output shell script: Help file 'pdftotext'
(*
Catalog/User Guides/PROCAD24 copia.pdf"
		"pdftotext version 3.01
Copyright 1996-2005 Glyph & Cog, LLC
Usage: pdftotext [options] <PDF-file> [<text-file>]
  -f <int>          : first page to convert
  -l <int>          : last page to convert
  -layout           : maintain original physical layout
  -raw              : keep strings in content stream order
  -htmlmeta         : generate a simple HTML file, including the meta information
  -enc <string>     : output text encoding name
  -eol <string>     : output end-of-line convention (unix, dos, or mac)
  -nopgbrk          : don't insert page breaks between pages
  -opw <string>     : owner password (for encrypted files)
  -upw <string>     : user password (for encrypted files)
  -q                : don't print any messages or errors
  -cfg <string>     : configuration file to use in place of .xpdfrc
  -v                : print copyright and version info
  -h                : print usage information
  -help             : print usage information
  --help            : print usage information
  -?                : print usage information
*)

In another thread today, there was a recommendation to read Apple’s page on how to integrate shell scripting and AppleScript. I would say it is required reading:
http://developer.apple.com/technotes/tn2002/tn2065.html

Your file path has a space in it. That is not allowed in Unix file paths. There are various ways to escape it, especially since it is hard-coded in this case. But there is a special AppleScript command to do so, which can be used in cases where the path is not hard-coded also.

set ff to POSIX path of (path to documents folder)
set the_file to quoted form of (ff & “Catalog/User Guides/PROCAD24 copia.pdf”)

You need to do it after you’ve put paths together, which is often kind of a PITA, if you’re using parts of paths in various ways. But otherwise it works well.

Here is an example I wrote for myself.


set theFile to choose file -- of type "PDF "
set posFile to quoted form of POSIX path of theFile

do shell script "/usr/local/bin/pdftotext -enc 'UTF-8' -eol unix -nopgbrk " & posFile
-- creates same-named file with ".txt" extension in same folder as ".pdf" file
-- encoding UTF-8, end of lines Unix (ASCII 10)
-- no page break characters (form feed, ASCII 12)

U…o…
your code requires major knowledge of shell commands as described in the (shell program specific) man page of pdftotext. Unfortunately, shell scripts aren’t my specialities.
I’ve to work closer with shells, a bit every day, and so on. Man pages aren’t really understandable, and i would need a lot of templates to study the right syntaxes, combinations and behaviours of shell scripts.
Nevertheless, thanks for the enlightment, Fenton.