Can't run Java tool with AppleScript

I’ve cheated again, but I hope this is ok and won’t cause any problems:

tell application "Finder" to move (every file of folder source_location whose name contains ".out.") to folder target_location
tell application "Finder" to move (every file of folder source_location whose name contains "xlf") to folder target_location
tell application "Finder" to move (every file of folder target_location whose name contains "xlf.src") to folder source_location

Not very graceful, probably, but does seem to work.

Thanks,

Bowjest

Yes

tell application "Finder" to move (every file of folder source_location whose name contains "xlf" and name does not contain "xlf.src") to folder target_location

But this might be the same

tell application "Finder" to move (every file of folder source_location whose name ends with "xlf") to folder target_location

Well! I wasn’t that far off for a change. :slight_smile:

works great now.

I really do appreciate it. This is going to save me loads of time and moving about between Finder windows.

Have a good weekend,

Bowjest

I’ve added one last refinement to this XLIFF creation script so that you can choose the source and target language listings in the XLIFF file itself:

# Create XLIFF files from files in project source directory
	
	set src_lang to {"German", "Dutch"}
	set src_langSelect to (choose from list src_lang with prompt "Make Source Language Selection:" without multiple selections allowed) as text
	if src_langSelect is "German" then
		set sourceLanguage to {"de-de"}
	else if src_langSelect is "Dutch" then
		set sourceLanguage to {"nl-nl"}
	end if
	
	set trg_lang to {"EN-GB", "EN-US"}
	set trg_langSelect to (choose from list trg_lang with prompt "Make Target Language Selection:" without multiple selections allowed) as text
	if trg_langSelect is "EN-GB" then
		set targetLanguage to {"en-gb"}
	else if trg_langSelect is "EN-US" then
		set targetLanguage to {"en-us"}
	end if
	
	set default_folder_Location to (path to home folder as text) & "01 Translations:03 Projects:"
	set project_location to (choose folder with prompt "Folder :" default location alias default_folder_Location) as text
	set project_location_POSIX to POSIX path of project_location -- POSIX path representation of project_location
	set source_location to project_location & "source:"
	set source_location_POSIX to POSIX path of source_location -- POSIX path representation of source_location
	
	do shell script "cd " & quoted form of source_location_POSIX & " ; java -jar /Applications/okapi-apps/lib/tikal.jar -x -sl " & sourceLanguage & " -tl " & targetLanguage & " *.*"
	
	display alert "XLIFF file created"

This works fine, but I’d like to add a default answer for both the source and target language code selections (German and EN-GB respectively). The problem I’m having, however, is that no matter where I put in and entry for default answer, I get an error about expecting one thing but getting another. Here is an example:

set src_langSelect to (choose from list src_lang with prompt "Make Source Language Selection:" default answer "German" without multiple selections allowed) as text

Again, a syntax error on my part, but I’ve tried to follow the analogy of how folders are referenced in the script such as:

set project_location to (choose folder with prompt "Folder :" default location alias default_folder_Location) as text

But obviously this isn’t correct in this instance.

Any advice appreciated.

Bowjest

Ok, I’ve just found the error.

The reference needs to be “default items” and yes, it has to be “items” (plural) even though it’s a singular choice:

set src_langSelect to (choose from list src_lang with prompt "Make Source Language Selection:" default items "German" without multiple selections allowed) as text

I hope this helps others.

Bowjest

actually default items expects a list of items and
without multiple selections allowed is the default setting, so you can omit it


set src_langSelect to (choose from list src_lang with prompt "Make Source Language Selection:" default items {"German"}) as text