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 duplicate csvfile
                    set name extension of theDupe to "txt"
          end tell
          tell application "Microsoft Excel"
  open text file filename theDupe data type delimited field 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 as theworksheet filename tempname file format Excel 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??

This actually works, I just need to rename "theDupe" file at the end to take off the " copy"
on run
          set csvfile to (choose file) as alias
--tell application "Finder" to set parentFolder to container of file csvfile
--tell application "Finder" to set tempname to (parentFolder as string) & (name of csvfile as text)
--display dialog "" & tempname
          tell application "Finder"
                    set theDupe to (duplicate file csvfile) as alias
                    set name extension of theDupe to "txt"
  --display dialog theDupe as string
          end tell
          tell application "Microsoft Excel"
  open text file filename (theDupe as string) data type delimited field 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 as theworksheet filename (theDupe as string) file format Excel XML file format
          end tell
--tell application "Finder" to delete file (theDupe as string)
          tell application "Finder" to set name extension of theDupe to "xlsx"
end run

Similar Messages

  • When i look at how much hard drive space i have available, my mac says i have 250 gigs used up in backup.  I can not find this backup file to delete it and free up the space

    When i look at how much hard drive space i have available, my mac says i have 250 gigs used up in backup.  I can not find this backup file to delete it and free up the space

    OmniDiskSweeper is a free utility that checks HD space.
    FreeSpace cost $1 or is a free utility that checks HD space.
    SpaceControl is a free utility that checks HD space.

  • It can't find URL when i use HLS for vod and the vod file name contain Chinese.

    It can't find URL when i use HLS for vod and the vod file name contain Chinese。eg: http://127.0.0.1:8134/hls-vod/你好.mp4.m3u8.
    How does it support Chinese path?

    To answer the post title FireFox save all downloads automatically in the download folder, which you can find in the Documents folder. If you want to choose where to save your downloads go to tools>options>check always ask me where to save files.
    Secondly, I am assuming you have IE 8 installed as this is the only version that supports this fix that is currently not in beta. Go to control panel>internet options>advanced tab and reset the settings at the bottom. This may or may not fix the problem but it is a good first step.

  • I have downloaded, extracted and installed Elements 12 but it will not open nor can I find the Adobe file in the file where I installed it to..  When I've tried to download and install again

    I have downloaded, extracted and installed Elements 12 but it will not open nor can I find the Adobe file in the file where I installed it to..  When I've tried to download and install again it says that the "Object Already Exists."  It may exists, but it is not visible in the file or in my list of programs on the Startup Menu.

    cactisken
    You should not have to uninstall Premiere Elements 12/12.1 in order to install and run Premiere Elements 13 on the same computer unless your computer is overloaded and the computer resources are compromised. Just use one program at a time.
    Can you still use 12/12.1 on this same computer that will not let you use 13?
    What specific Window operating system are you using?
    Let us go through the usual drill...
    1. Does the problem exist with and without the antivirus and firewall(s) disabled?
    2. Are you using a pen and tablet device instead of a mouse?
    3. Did you install the program with antivirus and firewall(s) disabled?
    4. Disable the SLCache Folder found in Windows 7, 8, or 8.1 64 bit
    Local Disk C
    Program Files (x86)
    Common Files
    Adobe
    and in the Adobe Folder should be the SL Cache Folder that you delete or disable by renaming the Folder
    from SLCache to SLCacheOLD.
    5. Are you running the program as Administrator and is the latest version of QuickTime installed on the same
    computer as Premiere Elements 13?
    Let us start here and then decide what next.
    Thank you.
    ATR

  • IWeb works, but I can't find the domain file!!!!

    OK - this one has had me stumped for a few days now... I have iWeb (vs. 1.1.2 - from the '06 iLife). I need to find the domain file. It isn't in the home/library/app. support/iWeb folder. I didn't move it. I searched for it using command-F and using spotlight on my computer.
    iWeb is to reset and start from scratch if there isn't a domain file on your hard drive. So I know it's there somewhere (at least, I think it is?). My site is there. I can publish. I can make changes, however I can't find the domain file to make a back up of it. I don't think that I made it invisible - could I have somehow done that? And if so, is it possible to find it? I believ the program only works if the file is named "domain" so I don't think that I could have accidentally renamed it.
    Is there someone out there who can help me? I don't want to have to start from scratch and rebuild the websites.
    Thanks for your input!

    This is from Multisite's Technical Page:
    Technical Information
    While you don’t need to understand how data is stored to use Multisite for iWeb it can be helpful occasionally to understand what is going on behind the scenes. At a nuts and bolts level Multisite for iWeb stores all of its sites in your home folder’s Documents folder in a single package (which is really a fancy folder dressed up to look like a file) called “Multisite for iWeb Data.mfi.”
    You can open that package like this.
    Once you get your domain file straightened out I'd definitely get Varkgirl's Automator application to make frequent backups of that file. You can get it Varkgirl's iWeb Tips and Tricks site.

  • Sedname - Batch rename files using sed

    Renaming files using sed is nothing new, but this script makes the process a little more friendly and adds a few features, including insertion of sequential numbers and a simulation mode.  The output of any find command can also be piped through sedname.
    sedname version 1.0.0
    Batch-renames files using a sed script
    Usage: sedname [OPTIONS] SEDSCRIPT FILE ...
    Usage: find [...] | sedname [OPTIONS] SEDSCRIPT
    Example: sedname 's/\(.*\)\.jpg/\1.jpeg/' *.jpg
    Example: find /mypics | sedname 's/\(.*\)\.jpg/\1.jpeg/'
    OPTIONS:
    --sim simulate only
    --dir rename directories too
    Use #D to insert a number with D digits forming a unique filename
    Example: sedname 's/thisname.*/thatname#3/' *
    ( changes thisname* to thatname001, thatname002, ... )
    Use #0 in replacement name to insert a number if needed
    Example: sedname 's/thisname.*/thatname#0/' *
    ( changes thisname* to thatname, thatname1, thatname2, ... )
    http://igurublog.wordpress.com/download … t-sedname/
    http://aur.archlinux.org/packages.php?ID=37707

    What does it have over zsh's zmv:
    # Remove illegal characters in a fat32 file system. Illegal characters are
    # / : ; * ? " < > |
    # NOTE: ``-Q'' and (D) is to include hidden files.
    $ unwanted='[:;*?\"<>|]'
    $ zmv -Q "(**/)(*$~unwanted*)(D)" '$1${2//$~unwanted/}'
    # Changing part of a filename (i. e. "file-hell.name" -> "file-heaven.name")
    $ zmv '(*)hell(*)' '${1}heaven${2}'
    # or
    $ zmv '*' '$f:s/hell/heaven/'
    # remove round bracket within filenames
    # i. e. foo-(bar).avi -> foo-bar.avi
    $ zmv '*' '${f//[()]/}'
    # serially all files (foo.foo > 1.foo, fnord.foo > 2.foo, ..)
    $ ls *
    1.c asd.foo bla.foo fnord.foo foo.fnord foo.foo
    $ c=1 zmv '*.foo' '$((c++)).foo'
    $ ls *
    1.c 1.foo 2.foo 3.foo 4.foo foo.fnord
    # Rename "file.with.many.dots.txt" by substituting dots (exept for the last
    # one!) with a space
    $ touch {1..20}-file.with.many.dots.txt
    $ zmv '(*.*)(.*)' '${1//./ }$2'
    # Remove the first 4 chars from a filename
    $ zmv -n '*' '$f[5,-1]' # NOTE: The "5" is NOT a mistake in writing!
    # Rename names of all files under the current Dir to lower case, but keep
    # dirnames as-is.
    $ zmv -Qv '(**/)(*)(.D)' '$1${(L)2}'
    # replace all 4th character, which is "1", with "2" and so on
    $ zmv '(???)1(???[1-4].txt)' '${1}2${2}'
    # Remove the first 15 characters from a string
    $ touch 111111111111111{a-z}
    $ zmv '*' '$f[16,-1]'
    # Replace spaces (any number of them) with a single dash in file names
    $ zmv -n '(**/)(* *)' '$1${2//( #-## #| ##)/-}'
    # or - with Bash
    $ find . -depth -name '* *' -exec bash -c '
    > shopt -s extglob
    > file=$1
    > dir=${file%/*}
    > name=${file##*/}
    > newname=${name//*([ -]) *([ -])/-}
    > mv -i -- "$file" "$Dir/$newname"' {} {} \;
    # Clean up file names and remove special characters
    $ zmv -n '(**/)(*)' '$1${2//[^A-Za-z0-9._]/_}'
    # Add *.py to a bunch of python scripts in a directory (some of them end
    # in *.py and give them all a proper extension
    $ zmv -n '(**/)(con*)(#qe,file $REPLY | grep "python script",)' '$1$2.py'
    # lowercase all extensions (i. e. *.JPG) incl. subfolders
    $ zmv '(**/)(*).(#i)jpg' '$1$2.jpg'
    # Or - without Zsh
    $ find Dir -name '*.[jJ][pP][gG]' -print | while read f
    > do
    > case $f in
    > *.jpg) ;
    > *) mv "$f" "${f%.*}.jpg" ;
    > esac
    > done
    # remove leading zeros from file extension
    $ ls
    filename.001 filename.003 filename.005 filename.007 filename.009
    filename.002 filename.004 filename.006 filename.008 filename.010
    $ zmv '(filename.)0##(?*)' '$1$2'
    $ ls
    filename.1 filename.10 filename.2 filename.3 filename.4 filename.5 ..
    # renumber files.
    $ ls *
    foo_10.jpg foo_2.jpg foo_3.jpg foo_4.jpg foo_5.jpg foo_6.jpg ..
    $ zmv -fQ 'foo_(<0->).jpg(.nOn)' 'foo_$(($1 + 1)).jpg'
    $ ls *
    foo_10.jpg foo_11.jpg foo_3.jpg foo_4.jpg foo_5.jpg ...
    # adding leading zeros to a filename (1.jpg -> 001.jpg, ..
    $ zmv '(<1->).jpg' '${(l:3::0:)1}.jpg'
    # See above, but now only files with a filename >= 30 chars
    $ c=1 zmv "${(l:30-4::?:)}*.foo" '$((c++)).foo'
    # Replace spaces in filenames with a underline
    $ zmv '* *' '$f:gs/ /_'
    # Change the suffix from *.sh to *.pl
    $ zmv -W '*.sh' '*.pl'
    # Add a "".txt" extension to all the files within ${HOME}
    # ``-.'' is to only rename regular files or symlinks to regular files,
    # ``D'' is to also rename hidden files (dotfiles))
    $ zmv -Q '/home/**/*(D-.)' '$f.txt'
    # Or to only rename files that don't have an extension:
    $ zmv -Q '/home/**/^?*.*(D-.)' '$f.txt'
    # Recursively change filenames with characters ? [ ] / = + < > ; : " , - *
    $ chars='[][?=+<>;",*-]'
    $ zmv '(**/)(*)' '$1${2//$~chars/%}'
    # Removing single quote from filenames (recursively)
    $ zmv -Q "(**/)(*'*)(D)" "\$1\${2//'/}"
    # When a new file arrives (named file.txt) rename all files in order to
    # get (e. g. file119.txt becomes file120.txt, file118.txt becomes
    # file119.txt and so on ending with file.txt becoming file1.txt
    $ zmv -fQ 'file([0-9]##).txt(On)' 'file$(($1 + 1)).txt'
    # lowercase/uppercase all files/directories
    $ zmv '(*)' '${(L)1}' # lowercase
    $ zmv '(*)' '${(U)1}' # uppercase
    # Remove the suffix *.c from all C-Files
    $ zmv '(*).c' '$1'
    # Uppercase only the first letter of all *.mp3 - files
    $ zmv '([a-z])(*).mp3' '${(C)1}$2.mp3'
    # Copy the target `README' in same directory as each `Makefile'
    $ zmv -C '(**/)Makefile' '${1}README'
    # Removing single quote from filenames (recursively)
    $ zmv -Q "(**/)(*'*)(D)" "\$1\${2//'/}"
    # Rename pic1.jpg, pic2.jpg, .. to pic0001.jpg, pic0002.jpg, ..
    $ zmv 'pic(*).jpg' 'pic${(l:4::0:)1}.jpg'
    $ zmv '(**/)pic(*).jpg' '$1/pic${(l:4::0:)2}.jpg' # recursively
    (from zsh-lovers)
    Edit: tried it now, and had to remove this silly block to make it let me use alternate delimiters:
    if [ "${sedscript:0:2}" != "s/" ]; then
    echo "Invalid sed script: $sedscript" > /dev/stderr
    exit 1
    fi
    Last edited by JohannesSM64 (2010-05-31 15:29:44)

  • I backup my iphone on my pc and copy backup file into drive D then i setup new OS on my pc. after that i copy the backup file into itunes backup folder but itunes can't find the backup file to restore my iphone. how can i restore my iphone?

    i backup my iphone on my pc and copy backup file into drive D then i setup new OS on my pc. after that i copy the backup file into itunes backup folder but itunes can't find the backup file to restore my iphone. how can i restore my iphone?

    Don't you just love changes in interfaces?
    I found the answer to my question.
    When you attach a device (iPhone, iPad) to your Mac, in iTunes 12 in appears as a tiny icon in the second "row" of the iTunes display. Click the icon and the familiar iTunes display for the device appears. From there, on the Summary screen, you can see the dates of the backups of the device (iCloud and backup to the computer). You can also use the button to backup to the computer.

  • My LV program can't find the iak file when the program is loaded from a different PC.

    Hello all,
    My LV vi with Fieldpoint I/O and it's IAK file are stored on the company network.  If I load and run the LV vi from the PC it was developed on, everything is fine.  If I load and run on a different PC (that has an identical install of LV), the LV vi can't find the IAK file (all of the I/O pointers to the file are grayed out.) 
    Also, if I make an EXE out of the vi on the machine that can find the IAK, it won't find it if it's run from the other machine.
    It is not related to whether one machine has different "rights", as they are identical.  It's not related to different installs of LV, as they are identical.   
    I have found that this is related to the network login name/password, and to the machine's network name.  If I login on the second machine and try to run the program, it won't find the IAK.  If I point it to the IAK it will run.  If I save it and log out, and then login as a different user with the same rights on the second machine, it won't find the IAK again, until I re-point it there when I re-run it.  This is true for both the vi and the EXE.
    This problem makes deploying the EXE difficult to different machines, as the first time it's run, the EXE has to be pointed to the IAK.  Pointing the EXE to the IAK is difficult as these installations have no keyboard or mouse.
    Does anyone have any ideas on how to fix this so the LV vi or it's EXE finds the IAK from no matter where it's loaded from?
    Thanks,
    Mike

    Laura,
    I figured I'd continue this thread because it's along he same line..
    I have two Fieldpoint systems. They are identical, except for one thing...one has an AI-110 in position 7...the other has nothing. Both have the same IP address, etc and I swap the ethernet cable between them when I want to select which one I use.  I use a dedicated ethernet card to the FP processor...and it's not the company net.
    There are two IAK files...one for the system with the AI-110, one for the system without the AI-110. The two IAKs are in different paths.
    Before I had the system and the IAK without the AI-110, I made an EXE of the code that woked with the AI-110, and it worked fine.
    But now if I run the EXE after I've used MAX and opened the IAK without the AI-110, the EXE won't read the AI-110!  I have to go back into MAX and open the IAK that has the AI-110 in it, close MAX and restart the EXE for the EXE to see the AI-110.  (Max is NOT SET to "Download Items on Save")
    I looks like the EXE is looking at MAX to get the IAK or a pointer to the IAK.
    Did I build my EXE incorrectly?  Shouldn't an EXE completely ignore MAX once it's made?
    Thanks,
    Mike

  • Can't find my data file to back up, so I can uninstall and reinstall the software. (Windows, Vista & Palm version 6.0.1)

    I can't find my data file, in order to back it up.  After going to Documents - Palm One, the only thing that looks like a user name is a file with no data.  Somewhere there has to be another file with all my data, since data is available when I open the Palm One software on my computer.  After backing it up, I want to uninstall and reinstall the Palm One software.  I'm hoping this resolves my inabilty hot sync.  Thanks!  Lauraflavin.
    Post relates to: Tungsten T5

    If you're using XP, your data is here:
    C:\Program Files\Palm (or PalmOne)\ your Hotsync Name abbreviated \
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • Hello! I have one iTunes library on my iPod and one iTunes library on my computer. When I connect my iPod touch to my PC, however, I cannot find any files in my iPod except for pictures. How can I find the music files so I can add them to my iTunes?

    Hello! I have one iTunes library on my iPod and one iTunes library on my computer. When I connect my iPod touch to my PC, however, I cannot find any files in my iPod except for pictures. How can I find the music files so I can add them to my iTunes?

    You can't do that.
    And before you decide to store any music that you own on a computer at work, talk to your IT department. Many organizations do not permit it for legal reasons. Standard policies are that anything stored on company owned computers is the property of the company. It could not be legally stored on their machines unless you transfer the licenses and all copies, physical and digital, to the company, meaning you no longer own the music. If they were to be audited and could not prove that they own the music, they would be subject to copyright violation penalties. Just use your iPod when you're at the office if you want to listen to music.

  • Where can i find the cached file?

    where can i find the cached file?.
    while one video was getting cached . I could see the cached file in the cache directory that mozilla firefox uses which in my pc is .....Local Settings\Application Data\Mozilla\Firefox\Profiles\uujksq39.default\Cache. but later on when the full video was completely cached i couldnt find the file existing in that directory and i still have my session of that firefox opened and can watch the video from the firefox session.
    since the cached video is still there ,there most be some place where the firefox is storing that file. is it the case that when the file is big (greater than some threshold value) firefox stores in some other directory?

    You can do a search an the about:cache page.

  • Can't Find New Domain File

    I am in the process of building a new website in iWeb '09 for the first time since upgrading to Lion but can't find the domain file I'm working on so as to make a backup. I have run the script that makes the Library folder visible, since Lion hides this folder, but the Application Support folder in Library doesn't contain a folder for iWeb. I have searched and searched for domains and .site files with no luck. Fortunately, I can open the new site in iWeb and update and publish, but I have no idea where it is finding the domain file that it is opening. As you can imagine, I'm very uneasy about not being able to back up the site as I invest more work into it.
    I have two other iWeb sites that were created prior to the Lion upgrade. Each is in a separate account on my iMac. I had moved the domain files for these sites out of the Library/Application Support/iWeb folders to more easily accessible folders prior to the Lion upgrade, so they are fine.
    It's the new site that is causing me concern.
    Interestingly, when I move one of the old domains to a new account on my iMac as a test, when I double click on it, iWeb launches but wants me to create a new website rather than opening the site associated with the old domain file.
    Any suggestions will be appreciated.

    Use the freeware app Find File to track down the Domain - or Domain.sites2 - file...
    http://www.macupdate.com/app/mac/30073/find-file
    See this page for info about opening Domain files using Lion and Mountain Lion...
    http://www.macupdate.com/app/mac/30073/find-file
    Also note that you don't have to run a script to show the user Library. Just open the Finder Go menu while holding down the option key.
    On the same page you will find a link to the freeware Mountain Tweaks which will hide/show the library plus a lot of other exciting tweaks.

  • I Just converted my iPhoto library to Photos. Now I can't find my RAW files. I need to have all the images in my old library show up in their RAW format.

    I Just converted my iPhoto library to Photos. Now I can't find my RAW files. I need to have all the images in my old library show up in their RAW format.

    Unfortunately no - Photos use extensions and the vendor (adobe) will have to implement the extension to allow external edits in PS or PSE
    For now you must export the photo, edit and then import - not great but a work arond
    And you can continue to use iPhoto until Photos meets your needs - launch it in your applications folder - if you need assistance on this see Why won't my iPhotos open?
    LN

  • In iPhoto, how can I find a particular event using the search function?, In iPhoto, how can I find a particular event using the search function?

    In iPhoto, how can I find a particular event using the search function?

    NO - read my last answer over a year ago
    That is because iPhoto is all about photos - not about files
    You do not access the piles in iphoto - you access the photos using either iPhoto or the media browser - see this user tip for photo access details
    LN

  • How can I find out those files whose name has space character?

    Hi
    How can I find out the files whose name has space character in a whole file system?
    Thanks
    Jerry

    thank you all
    I can use this command to find out like
    $find ./ -type f -exec ls -1 {} \; 2>/dev/null | grep " "
    ./space in name
    while, I modify above a little to find out a spcific file systems like below:
    $find /bbj* -type f -exec ls -1 {} \; 2>/dev/null | grep " "
    /bbj14/appl/oracle/prdrep/S_STATIC_TAB_05.dbf
    --while, I didn't see any space character in file name "S_STATIC_TAB_05.dbf"
    what is wrong?
    thanks

Maybe you are looking for

  • CUP integration with Abode online forms

    Hi forums gurus, We are currently implementing GRC AC version 5.3, SP15.  The client has the requirement to use Adobe online forms to capture the request details, this must then feed into CUP and populate the landing page.  1) Is this scenario possib

  • Does a single transaction, spreeds accross multiple rollback segments?

    Hi, Does a single transaction, spreeds accross multiple rollback segments? What if , there is not enough space in the allocated rollback segment? Thanks Naveen.

  • My computer when i download vidoes

    since christmas morning( not before) whenever i download a video, the second it finishes, a blue screen pops up and says that my computer had to shut down. its when itunes closes the file. also, it erases whatever the file was. for instance, i bought

  • CSS help

    www.bristolequestrianservices.co.uk I am trying to put my contact details below my facebook icon.  I have large gaps, how do I get them so they each line stacks nicely.  I am most probably doing it wrong anyway but can you please help. I have include

  • No sound after using quicktime pro???

    I converted a video and added it to itunes but it played with no sound. Please help i bet there is a stuipid mistake im making here im pretty mad that i just spent 30 dollars on quicktime pro only to have problems.