bencfd Posted September 10, 2013 Share Posted September 10, 2013 Hi, I'm having trouble creating a workflow. Based on help found on macscripter.net, I wrote an AppleScript to change decimal and thousands separator within csv files. tell application "Finder" to set FileToEdit to selection as string set AccessToFile to open for access file FileToEdit with write permission set CSVContent to read file FileToEdit to switchText from t to r instead of s set d to text item delimiters set text item delimiters to s set t to t's text items set text item delimiters to r tell t to set t to item 1 & ({""} & rest) set text item delimiters to d t end switchText switchText from CSVContent to "." instead of "," set FirstStepText to result switchText from FirstStepText to "," instead of ";" set TextToWrite to result set eof of file FileToEdit to 0 write TextToWrite to AccessToFile close access AccessToFile The script works fine from the Finder selection. However, I would like to turn into an Alfred workflow, using a file filter. To do so, the file filter searches for csv files, and I changed the first line of the script to: set FileToEdit to POSIX file q ... or other variants, but nothing worked. Do you have any idea to fix it? Thanks! Link to comment
jdfwarrior Posted September 10, 2013 Share Posted September 10, 2013 Hi, I'm having trouble creating a workflow. Based on help found on macscripter.net, I wrote an AppleScript to change decimal and thousands separator within csv files. tell application "Finder" to set FileToEdit to selection as string set AccessToFile to open for access file FileToEdit with write permission set CSVContent to read file FileToEdit to switchText from t to r instead of s set d to text item delimiters set text item delimiters to s set t to t's text items set text item delimiters to r tell t to set t to item 1 & ({""} & rest) set text item delimiters to d t end switchText switchText from CSVContent to "." instead of "," set FirstStepText to result switchText from FirstStepText to "," instead of ";" set TextToWrite to result set eof of file FileToEdit to 0 write TextToWrite to AccessToFile close access AccessToFile The script works fine from the Finder selection. However, I would like to turn into an Alfred workflow, using a file filter. To do so, the file filter searches for csv files, and I changed the first line of the script to: set FileToEdit to POSIX file q ... or other variants, but nothing worked. Do you have any idea to fix it? Thanks! From a file filter, it would pass the file path and name to the next step (your script) in the {query} variable. So, try setting FileToEdit to "{query}". I think that should get you going Link to comment
bencfd Posted September 10, 2013 Author Share Posted September 10, 2013 From a file filter, it would pass the file path and name to the next step (your script) in the {query} variable. So, try setting FileToEdit to "{query}". I think that should get you going Ah, I got confused between q and {query}! So, the first line is set FileToEdit to POSIX file "{query}" ... and it works perfectly. Thank you! Link to comment
jdfwarrior Posted September 11, 2013 Share Posted September 11, 2013 Ah, I got confused between q and {query}! So, the first line is set FileToEdit to POSIX file "{query}" ... and it works perfectly. Thank you! You're very welcome. Glad you got it sorted out Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now