Nasty line break...

I’m trying to create an application that performs a shell script on a file thats dropped onto an Image well…

The problem is, that I want to be able to it to more than a single file, so using a script I made it to where it line breaks after every file…this is where the problems begin.

It has a line break before the first file path, like so:

/Users/username/Desktop/file.mov

So naturally it results in error.

I have tried every trim, replace, remove line breaks, etc. etc script I can get my hands on. and none of them have worked. All I want to do…is remove the line break before the first paragraph, while leaving the rest of the file paths alone…Help?

I’ve spent a total of 5 hours or so just on this one part of my app. It’s driving me to insanity.

I don’t understand. When you implement drag and drop into your app and get the files from the pasteboard, you get a list of the paths that you can then iterate through. This isn’t one long string with all the files, all the paths are unique items in the list without any blanks. Isn’t this how you’ve enabled the drag and drop in your app? If not, you need to post more code so we can see what’s really going on in order to offer a solution.

Jon

My code:

[code]on drop theObject drag info dragInfo
set preferred type of pasteboard of dragInfo to “file names”
set theFiles to contents of pasteboard of dragInfo
set x to formatFiles(theFiles)
tell window “dumbwindow”
set the contents of text view “duh” of scroll view “duh” to x
end tell
end drop

on formatFiles(pathsOfFiles)
set n to 1
set filenames to “”
set filelist to {return}
repeat until n is the ((length of pathsOfFiles) + 1)
set n_file to item n of pathsOfFiles
if n is less than (length of pathsOfFiles) then
set filenames to filenames & “"” & POSIX path of n_file & "" "
set filelist to filelist & POSIX path of n_file & {return}
else
set filenames to filenames & “"” & POSIX path of n_file & “"”
set filelist to filelist & POSIX path of n_file
end if
set n to n + 1
set filelist to filelist as text
end repeat
end formatFiles[/code]
As far as what I meant.

The problem is, it line breaks before the first path, which renders the whole variable useless, because I can’t figure out a way to remove the line break before the beginning of the paths.

It returns:

(blank line) /Users/user/path /Users/user/path
when I need it to return

/Users/user/path /Users/user/path
Does that clear it up some? Basically theres a linebreak before the paths I need, as a result of the funciton I’m using to seperate the paths of files dropped, and I can’t figure out how to remove it.

Try this:

on drop theObject drag info dragInfo
	set preferred type of pasteboard of dragInfo to "file names"
	set theFiles to contents of pasteboard of dragInfo
	set contents of text view "duh" of scroll view "duh" of window "dumbwindow" to my formatFiles(theFiles)
end drop

on formatFiles(pathsOfFiles)
	repeat with i from 1 to (count pathsOfFiles)
		set item i of pathsOfFiles to (POSIX path of item i of pathsOfFiles)
	end repeat
	tell (a reference to my text item delimiters)
		set {old_tid, contents} to {contents, return}
		set {pathsOfFiles, contents} to {pathsOfFiles as Unicode text, old_tid}
	end tell
	return pathsOfFiles
end formatFiles

Jon

Allow me to put this into context for you my friend:

( : : )

Yes, that is your cookie! Thanks! adds this code to common resources