How to open renamed files?

Hi
I rename selected files and after that want to open them.
For my purpose renaming works well like this:
tell application "Finder"
set FilesToRENAME to selection
display dialog "Change what?" default answer ""
set ChangeFROM to text returned of the result
display dialog "Change to?" default answer ""
set ChangeTO to text returned of the result
set AppleScript's text item delimiters to {ChangeFROM}
set theCount to count of FilesToRENAME
repeat with x from 1 to theCount
try
set theName to name of item x of FilesToRENAME
set FirstNamePart to first text item of theName
set LastNamePart to second text item of theName
set newName to FirstNamePart & ChangeTO & LastNamePart
set name of item x of FilesToRENAME to newName
on error errStr number theNumber
activate
display dialog "Error in changing the Name " & theNumber & return & errStr ¬
& return & "Step " & x
end try
end repeat
set AppleScript's text item delimiters to ""
end tell
Now newly renamed files don't belong anymore to FilesToRENAME. So how to point to those files now (how to make a new list from those renamed files)? I was thinking to get a path to each file inside the repeat loop and replace the name, but couldn't do it.
Thank you for any help.
Vera

Pierre's method is pretty clever, but if you don't happen to be using a Finder selection (choose file for example), you can also use the interesting fact that an alias keeps track of an item even if it is moved or renamed.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
-- tell application "Finder" to set filesToRename to selection as alias list
set filesToRename to (choose file with multiple selections allowed)
set changeFrom to text returned of (display dialog "Change what?" default answer "")
set changeTo to text returned of (display dialog "Change to?" default answer "")
set renamedFiles to {} -- this will be the renamed files
repeat with aFile in filesToRename
set aFile to the contents of aFile
tell application "Finder" to set theName to name of aFile
try
set tempTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {changeFrom}
set firstNamePart to first text item of theName
set lastNamePart to second text item of theName
set AppleScript's text item delimiters to tempTID
set newName to firstNamePart & changeTo & lastNamePart
tell application "Finder"
set name of aFile to newName -- aFile points to the original file
update aFile -- give Finder a chance to catch up
set the end of renamedFiles to aFile -- aFile now points to the renamed file
end tell
on error errStr number theNumber
activate me
display alert "Error " & theNumber & " in changing the Name" message errStr
end try
end repeat
renamedFiles --> aliases to the renamed files
</pre>

Similar Messages

  • How to open a file created at the server through form/report at client end

    How to open a file created at the server through form/report at client end
    Dear Sir/Madame,
    I am creating a exception report at the server-end using utl file utility. I want to display this report at the client end. A user doesn't have any access to server. Will u please write me the solution and oblige me.
    Thanks
    Rajesh Jain

    One way of doing this is to write a PL/SQL procedure that uses UTL_FILE to read the file and DBMS_OUTPUT to display the contents to the users.
    Cheers, APC

  • HT4796 I have made a file using the Pages app.I mailed it to a friend.When she tried opening the same file on her pc at home , It did not open.Please help me as to how to open the file in the Microsoft word format on her pc.

    I have made a file using the Pages app.I mailed it to a friend.When she tried opening the same file on her pc at home , It did not open.Please help me as to how to open the file in the Microsoft word format on her pc.

    Send it as a PDF.

  • How to open CR2 files in photoshop elements 10

    Who knows how to open CR2-files from a Canon Powershot S100 in Photoshop Elements 10?

    Hi,
    The version of Camera Raw that you reported should support the S100 CR2 images.
    If you load the editor, go to the File menu and select Open, then point to the file, are you saying that it displays the error message?
    Have you tried opening the file with Canon's Zoombrowser?
    Which operating system are you running on?
    Brian

  • How to open *.pdf files in BOXI r2 inbox

    I am scheduling as  *.pdf file for deski report.After scheduling i am getting *.pdf in my inbox.if the report is deski or webi we can use FC_REPORT_ENGINE or WI_REPORT_ENGINE to open the report's using java code.In same way how to open *.PDF file in Inbox?
    Edited by: ramkishore kishore on Nov 7, 2008 8:31 AM
    Edited by: ramkishore kishore on Nov 7, 2008 8:31 AM

    Hi Ram,
    Following information might help you to resolve the issue.
    After logging into Desktop Intelligence, you may be presented with a message stating:
    u201CYou have received 1 document from users"
    Examining the Inbox from within the Desktop Intelligence client shows no objects visible in your Inbox.
    The object in your Inbox is in a format other than Desktop Intelligence format such as, PDF, XLS or other format. Therefore the object is not recognized by the Desktop Intelligence client inbox browser.
    Log in to Info View or the Central Management Console, browse to your Inbox and verify the file name and format that has been sent to your Inbox. The object may be saved, copied, moved or deleted as necessary.
    Regards,
    Sarbhjeet Kaur

  • How to open NRW-files in Lightroom 4?I

    just bought Nikon's Coolpix P7800. It says you can shoot in Raw. Now I want to open these files in LR, just like I'm used to with my SLR's. But Nikon uses the NRW-format for Raw and LR says it doesn't recognise the files. Does someone know if there's a way to convert and work with these files in LR 4?

    Thanks Jim for your response,
    I will upgrade to 5.3
    Kind regardsEut van Berkum
         Op woensdag 28 januari 17:04 2015 schreef JimHess <[email protected]> het volgende:
    how to open NRW-files in Lightroom 4?I
    created by JimHess in Photoshop Lightroom - View the full discussionThe only way to use those files with Lightroom 4 is to convert them to DNG using DNG converter 8.3 or higher. The camera wasn't supported in Lightroom until version 5.3. If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7140310#7140310 and clicking ‘Correct’ below the answer Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7140310#7140310 To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"  Start a new discussion in Photoshop Lightroom by email or at Adobe Community For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • How to open aspx. files in OS 10.8?

    is this the right place to ask how to open aspx. files in OS 10.8.2?

    Unfortunately aspx is a generic extender - it is a report generated by a server running Windows .net - it isn't an extender that actually tells what kind of file it is or what kind of data it holds. That's something you either have to know before hand so you can force the proper program to open it (or change the aspx extender to its real extender) or you have to find out what the file is.
    At work our system's report generator gives everything an aspx extender. When I generate a report I decide whether it should be a PDF, Excel file, etc. After downloading the file I change its extender appropriately.

  • How to open Zip Files in N900 ?

    Hi Guys,
    I wanted to know how to open Zip files in N900 ? is there a App available for it or what ?
    Thanks

    if you have rootsh installed, open up xterm and run these commands
    root
    apt-get install unzip-fm
    apt-get install unrar-fm
    as in the link from aspergerguy, you need the extra catalogs installed.
    once you have them installed you just need to click on the zipped file then it will unzip it to a folder of the same name

  • How to open raw files in elements 11

    how to open raw files in elements 11

    Hi Have tried to do that but get a box with message along top "The file aready exists in the catalog"  it is also showing the incorrect file path and saying not connected to the path I have found the photo in.  The only differenct is that elements it saying it is in E drive and I have it in C drive the rest of the path is the same.
    The photos have imported into the my folders but I can't open any, every one i've tried to open brings up the box "searching for missing file" There are no photos in E drive the path it is saying doesn't exist all photos are in c drive, very very frustrating

  • How to open .vnt files in iphone

    how to open .vnt files in iphone

    virtualscott wrote:
    I was revisiting the WWDC from June and Jobs mentioned the ability view
    iWork files on the iPhone. I have done a lot of searching and have not
    found any answers. Can someone help, please?
    You can view them as email attachments.

  • How to open TIF files in iPad

    How to open TIF files in iPad

    The Mail ap can handle TIFF files for viewing purposes. They can be saved to the Photos app (from Mail, or other apps such as DropBox), but I beleive they get converted to JPG in the process. There are also a number of third party apps that can at least view TIFF files.
    If you could describe exactly what it is you are trying to accomplish, someone may be able to provide more detailed assistancce.

  • How to open psb files in mac

    how to open psb files in mac

    No it isn't free but you can download a free trial version.
    http://www.adobe.com
    Afterward you can download GIMP it is free and will also change your PSB files.
    http://www.gimp.org

  • How to open sdf files in SQL server 2012?

    How to open sdf files in SQL server 2012?
     I couldn’t figure out how to open the sdf files in SQL server 2012
     Thank you
     Best
     Jamal

    I don't think it's hard if understood the question properly you can try this I do it most of the time and this might be the solution for you, sometimes minor simple click is a life saver:)
    1. 
    Open SQL Server Management Studio, or if it's running select File -> Connect Object Explorer... and click the
    connect drop down arrow
    2. 
    In the Connect to Server dialog you will see Database Enghine, Analaysis Servie on so on and you go head change Server type to
    SQL Server Compact Edition
    3. 
    From the Database file drop-down as shown below click the drop down arrow and select <
    Browse for more...>
    4. 
    And you will see C:\, D:\, G:\
    drive and so on and open, your SDF file where it is located
    I hope this has been informative for you and good luck
    Please remember to click “Mark as Answer” on the post that has answered your question as it is very relevant to other community members dealing with same problem in seeking the right answer

  • How to open the file types of iOSApp(ipa),EPUBFile(.epub) in windows 7(32 bit)

    How to open the file types of iOSAPP(ipa),EPUBfile(.epub) in windows 7(32 bit)

    iOS apps can be added to an iTunes library and thereafter transferred to an iOS device. They cannot be opened directly on a PC.
    epub files can be added to an iTunes library, and thereafter transferred to an iOS device where they can be read with the iBooks application. Files protected with Apple's DRM cannot be opened directly on a PC, though there are programs such as Kindle and Calibre that will open non-protected epub files.
    tt2

  • HOW TO OPEN WINDAT FILES

    How to open windat files which come along with E mails from microsoft users ?

    That is priceless, "you can ignore winmail.dat...."  No I can't. They are often a drawing or purchase order I require for a job.
    I am running outlook on my mac and I still can't open them. All my other devices open these attachments no problem (none of them are apple). The people sending me these attachments are using macs. The only thing that has changed since I started encountering this problem is my hardware. I still use outlook, I have the same email address. The PDF attachments are being sent by the same people in the same way. When I had an iphone they opened on there too. Why do all the people on this forum keep blaming microsoft. Why can't macs read microsoft RTF, much like gmail or yahoo manage to do.
    I cannot go asking busy project managers to send me attachments in a different format simply because I bought what I thought to be a decent computer.

Maybe you are looking for