Can't find a renamed file using Applescript
Here is what I'm trying to accomplish:
1) User selects .csv file
2) Finder duplicates file and renames as a txt file
3) Microsoft Excel imports this newly made file as a pipe delimited text file with text formatting in all cells (On a Mac, Excel won't take pipe delimited csv's, it automatically assumes they are comma delimited)
4) Microsoft Excel then saves this as the same name of the original user extraction location with the same name but in the .xlsx or XML format
Preferably with that duplicated file now gone, whether its used and converted with Excel, or later deleted from Finder.
Here's the code that I'm working with so far:
on run
set csvfile to (choose file) as alias
tell application "Finder" to set tempname to (name of csvfile as text) as text
--display dialog "" & tempname
tell application "Finder"
set theDupe to duplicatecsvfile
set name extension of theDupe to "txt"
end tell
tell application "Microsoft Excel"
open text filefilenametheDupedata typedelimitedfield info {{1, text format}, {2, text format}, {3, text format}, {4, text format}, {5, text format}, {6, text format}, {7, text format}, {8, text format}, {9, text format}, {10, text format}, {11, text format}, {12, text format}, {13, text format}, {14, text format}, {15, text format}, {16, text format}, {17, text format}, {18, text format}, {19, text format}} other char "|" with use other
set theworksheet to worksheet 1 of active workbook
save astheworksheetfilenametempnamefile formatExcel XML file format with overwrite
end tell
end run
The error I run into is that after it duplicates and renames the file, it is trying to refer to something that it can't find.
Please I'm stuck at this point, any suggestions or helpful hints?? 🙂
MacBook Pro (Retina, 15-inch, Early 2013), OS X Mavericks (10.9.2)