Trying to change the name of 1 file

I have searched the topic and have not found a solution that works for me,
I am trying to write an AppleScript that will change the name of a single file from path:old.txt to path:new.txt
I have tried
tell application "Finder"
set name of file "work.txt" to PartA & PartG & ticker & ".txt"
end tell
among others and always either receive an error message, access denied or unable to set old file name to new file name

You're missing the point.
set name of file "work.txt" to PartA & PartG & ticker & ".txt"
When you set the name of the file, the Finder needs two things - the original file that you're trying to rename, and the new name you want it to take.
In your revised script you're specifying the existing name (not path) of the file you want to change, and specifying its path along with the new name. That's the wrong way around.
Think of this command in the following manner:
set name of (original file specification) to (new file name)
Now, in the case of the 'original file specification' you need to provide enough information for the Finder to identify the file. You're just saying 'work.txt', but that is not enough (and that's why it's complaining). There could be a hundred 'work.txt' files spread around in different directories on your disk. How is the Finder supposed to know which one you want to change?
A better format would be:
tell application "Finder"
  set name of (file "work.txt" of path to desktop) to "ABC.txt"
end tell
In this way the Finder can absolutely identify which file you want to change (the file 'work.txt' that's on your desktop) and the new name you want it to take.
Now, if the file is not on your desktop you can amend the script to include the relevant path, e.g.:
tell application "Finder"
  set name of (file "work.txt" of folder "blah" of disk "disk name") to "ABC.txt"
end tell
This tells the Finder to look in the folder 'blah' on the specified disk.
You can also do this by including the path to the file in the form:
tell application "Finder"
  set name of (file "disk name:blah:work.txt) to "ABC.txt"
end tell
where you use : to delimit each folder in the path.
Hope that helps.

Similar Messages

  • Change the name of a file.

    Hello, I don't how can I change the name of a file ?.
    Somebody can help me, please?
    For example : c:\out\prove1.csv to  c:\out\prove1_09112007_163001.csv
    Thanks

    Another way would be to use the FILE_COPY and
    FILE_DELETE of the class CL_GUI_FRONTEND_SERVICES to first copy the file and then delete the other one.
    REgards,
    Rich Heilman

  • BEx Brodcaster for Workbook - Cannot change the name of attachment file.

    Dear All Experts,
    I am using the BEx Broadcaster to distribute report of workbook via email. The name of attchament file in email is the technical of workbook. I want change the name of attchment file and found this thread
    [Broadcasting Workbook - Change attachment filename|Broadcasting Workbook - Change attachment filename] that reference to method in background process. Can I create customize program or method to change the name of file.
    Thank you and really appreciate your help.
    Zilla D.

    Hello Zilla,
    By SAP methods, this is not possible. There is no way to do that. May you can suggest it on our Community of Innovation. See note 11.
    This is not only your concern. Some customers already request this functionallity.
    Best Regards,
    Edward John

  • I am trying to change the name in my "from" box

    I am trying to change the name in my "from" box. My name has changed and although I have changed the name on the account, I can't figure out how to make the default name in my "from" box change from my previous name to my new name.

    You may need to know that (in Snow Leopard at least) you specify multiple possible "From" email addresses as a list separated by commas.  Just type them into that little Email Address box*: they'll move over to make room.  Then, on your new messages from that point on, a pop-up menu will appear for the From field.  Neat, eh?
    *-- Notice that you can lie in this box.  Your ISP might not let you get away with it, but spammers use this loophole.
    --Gil

  • Trying to change the name of my home page

    This is the first time I have published a website. I just got my first mac last week and I am trying iweb for the first time. I go the sites out there without a problem, but then I decided I wanted my home page to be called "Home" instead of "Welcome. I attempted to change the name of the page and now everything is all screwed up. I made the changes in iweb and am trying to publish and I keep getting error messages. HELP!!!!!

    ldysnwbdr,
    Just change the name in the Site Organizer to your left in iWeb, and from the file menu, choose File/Publish All to .Mac.
    If you continue to get error messages post pack and tell us what they are. You may find a little help with error messages here.
    Mark

  • How can i change the name of this file?

    In finder, the file under "desktop".

    Click on the file to highlite it, and hit the return key. Edit text/file name.
    You can not change the Places name: Desktop
    Message was edited by: leroydouglas

  • Logic changing the names of audio files when I drag and drop into arrange

    i am dropping some 44.1/24 bit files into logic and for some reason out of nowhere the names of the files are changed. it removes digits i have entered in the file for identification purposes, so i am no longer sure what they are, and seems to be replacing it with "#". could it have something to do with import settings? i have not changed any...

    This happens because until recently Logic didn't handle long filenames very well.
    Long filename support was added in Logic 9.1.x so I recommend upgrading to that version - or using shorter file/pathnames.
    The #7875 bit appended to the name is the number of the disk block the file is stored at...

  • I tried to change the name of my device and now I cant sync anything and it says there is a problem with the disk and when I changed the name back it still said the same thing so I restored my ipod (not from itunes but on the ipod itsself)

    And now its saying my ipod is corrupt. None of my stuff was erased from itunes it was only erased from my ipod so why am I not able to just sync everything back onto my ipod? why is it doing this now? I think this is ridiculous that just changing one name would do this much damage.

    There is a backup plan after doing the Restore.  Read this.

  • How to open a file, change the name and write file

    Hi,
    I want to open an existing .dat-file in Labview, manipulate the data and save this data into a new file with a different file name.
    Though the name should be different I would like to use the old name and add something to it.
    (In my programm the .dat file containes the date and time the data was
    measured and I would like to keep this information in the filename.)
    For example: the original title is file1.dat now I want to save it as file1_manipulated.dat
    Is that possible? What is the best and easiest way to do it?
    Thanks a lot
    Chris

    Hi Mike,
    thanks for your help.
    This will give me my path in string format. But to open a new file and then write my data into it, I need a path format (see right side of png)
    Is that right?
    I attached a png, so you hopefully get an idea where this is going. (I know this won´t work yet)
    I open a file and this filename depends on the date and time the data was recorded. So I can´t work with a stringconstant.
    Sorry for this beginner questions - this stuff is absolutly new to me.
    Thanks in advance
    Chris
    Attachments:
    newfile.png ‏11 KB

  • Trying to change the name to the itunes account and made one myself because my sister use to use my computer and updating my apps where under her email now that i made my own i cant update anything on my phone its still showing my sisters email.

    basically my sister used my computer and everytime we had to update our apps it would be her email thats showing and thats when i knew that pw. since shes doesnt use it anymore i made my own and now it wont let me update it its still showing hers.

    To change the iCloud ID you have to go to Settings>iCloud, tap Delete Account, provide the password for the old ID when prompted to turn off Find My iDevice, then sign back in with the ID you wish to use. 
    If your sister doesn't know the password for her old ID, and if her old ID is an earlier version of her current ID, she needs to temporarily recreate the old ID so you can delete if from your phone using her current password.  To do this, have her go to https://appleid.apple.com, click Manage my Apple ID and sign in with her current iCloud ID.  Click edit next to the primary email account, change it back to her old email address and save the change.  Then edit the name of the account to change it back to her old email address.  You can now use the password for her current ID to turn off Find My iDevice on your device, even though it prompts you for the password for her old account ID.  After you do this, Next, have your sister recreate her current ID again by going back to https://appleid.apple.com and changing her primary email address and iCloud ID name back to the way it was.
    Then your can save any photo stream photos that you wish to keep to the camera roll on your device, then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted.  You will be prompted to either keep or delete the iCloud data from your device.  If the data is already in another account you can choose Delete.  If you need to migrate it to another account, choose Keep, then choose Merge when signing into the new account.

  • Trying to Validate the name of a file with a Validator

    Hi, Im trying to validate an file name that is sent with a form
    I want that the Validator Checks if the filename ends with some extensions (.jpg ,etcc) for only addmit one type of files (images)
    I ve build my own Pluggable Validator , but I dont know how to extract the filename from Validator.
    Can anyone help me??
    the Code is something like this
    where
    package jmar5439.webpage.validator;
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
    import java.io.Serializable;
    import org.apache.struts.action.*;
    import org.apache.commons.validator.ValidatorAction;
    import org.apache.commons.validator.*;
    import org.apache.commons.validator.Field;
    import org.apache.commons.validator.GenericValidator;
    import org.apache.commons.validator.util.ValidatorUtils;
    import org.apache.commons.validator.Validator;
    import org.apache.struts.validator.Resources;
    import org.apache.commons.logging.LogFactory;
    import jmar5439.webpage.action.InsertRoomAction;
    import org.apache.commons.logging.Log;
    public class ImageFileValidator implements Serializable {
    // public ImageFileValidator() {}
    public static boolean validateImageFile(Object bean, ValidatorAction va,
    Field field, ActionMessages errors,
    HttpServletRequest request, Validator validator) {
    String value = null;
    if (field.getProperty() != null && field.getProperty().length() > 0) {
    value = ValidatorUtils.getValueAsString(bean, field.getProperty());
    String file = new String(value);
    file = file.toLowerCase();
    if (!GenericValidator.isBlankOrNull(value)) {
    try {
    if (!file.endsWith(".jpeg") || !file.endsWith(".gif") ||
    !file.endsWith(".jpg")) {
    errors.add(field.getKey(),
    Resources.getActionMessage(request, va,
    field));
    return false;
    } catch (Exception e) {
    errors.add(field.getKey(),Resources.getActionMessage(request, va,field));
    return false;
    return false;
    return false;
    I ve declared
    <form-property name="file"
                   type="org.apache.struts.upload.FormFile"/>
    in struts-config file and
    <field property="file"
                        depends="imagefile">
    in validate file.
    Thanks

    I ve solved like this
    package jmar5439.webpage.validator;
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
    import java.io.Serializable;
    import org.apache.struts.action.*;
    import org.apache.commons.validator.ValidatorAction;
    import org.apache.commons.validator.*;
    import org.apache.commons.validator.Field;
    import org.apache.commons.validator.GenericValidator;
    import org.apache.commons.validator.util.ValidatorUtils;
    import org.apache.commons.validator.Validator;
    import org.apache.struts.validator.Resources;
    import org.apache.commons.logging.LogFactory;
    import jmar5439.webpage.action.InsertRoomAction;
    import org.apache.commons.logging.Log;
    import org.apache.struts.upload.FormFile;
    import org.apache.commons.beanutils.PropertyUtils;
    import java.lang.reflect.*;
    public class ImageFileValidator implements Serializable {
    // public ImageFileValidator() {}
    public static boolean validateImageFile(Object bean, ValidatorAction va,
    Field field, ActionMessages errors,
    Validator validator,
    HttpServletRequest request) {
    Log log = LogFactory.getLog(ImageFileValidator.class);
    //log.info(form.toString() );
    String value = ValidatorUtils.getValueAsString(
    bean,
    field.getProperty());
    if (!GenericValidator.isBlankOrNull(value)) {
    try {
    FormFile file = (FormFile) PropertyUtils.getSimpleProperty(bean,
    "file");
    String filename=file.getFileName().toLowerCase() ;
    //log.info("Filename:" + file.getFileName());
    if (filename.endsWith(".jpeg") ||
    filename.endsWith(".jpg") ||
    filename.endsWith(".gif")) {
    log.info("return true");
    return true;
    } else {
    errors.add(field.getKey(),
    Resources.getActionMessage(request, va,
    field));
    log.info("return false");
    return false;
    } catch (NoSuchMethodException ex) {
    errors.add(field.getKey(),
    Resources.getActionMessage(request, va,
    field));
    return false;
    } catch (InvocationTargetException ex) {
    errors.add(field.getKey(),
    Resources.getActionMessage(request, va,
    field));
    return false;
    } catch (IllegalAccessException ex) {
    errors.add(field.getKey(),
    Resources.getActionMessage(request, va,
    field));
    return false;
    //return false;
    // log.info("Entra0");
    /* if (field.getProperty() != null && field.getProperty().length() > 0) {
    // log.info("Entra");
    // value = ValidatorUtils.getValueAsString(bean, field.getProperty());
    value = ValidatorUtils.getValueAsString(bean, field.getProperty());
    String file = new String(value);
    file = file.toLowerCase();
    if (!GenericValidator.isBlankOrNull(value)) {
    // log.info("Entra2");
    try {
    if (!file.endsWith(".jpeg") || !file.endsWith(".gif") ||
    !file.endsWith(".jpg")) {
    errors.add(field.getKey(),
    Resources.getActionMessage(request, va,
    field));
    //log.info("Entra3");
    return false;
    } catch (Exception e) {
    errors.add(field.getKey(),Resources.getActionMessage(request, va,field));
    return false;
    return false;
    // return true;
    } else {
    return false;
    Remember to visit
    http://www.lloguerjove.com
    and
    http://www.alquilerjoven.com

  • Recently I noticed that when I change the name of a photo (correcting a mistake) it always goes back to the previous name, keeping the mistake I'm trying to correct. A spelling mistake, for example. As I keep my photos organized by name and not by date, t

    Recently I noticed that when I change the name of a photo (correcting a mistake) it always goes back to the previous name, keeping the mistake I'm trying to correct. A spelling mistake, for example. As I keep my photos organized by name and not by date, this is very annoying.
    And today it won't even read my camera's sd card, and I try with 2 different ones. If I restart the computer, leaving the memory card in, then it reads it; but if I pull it out and push it back in it doesn't see it. Whath am I doing wrong, if anything?
    Diane

    Where/how are you trying to change the name? If it is in Finder (after you've downloaded the pics to your desktop), highlight the pic icon and press Return. the name field will change and you can type in your new name. Hit Return again. That should make it "stick".  If you're trying to do it elsewhere, please post the steps that you've tried.
    As for your card: do you eject it properly? Either drag icon to trash or hit the eject symbol in the sidebar?

  • How do I change the name of the Home folder OSX 10.9

    Hi there,
    I am trying to change the name of the Home folder on my Macbook Pro running OSX 10.9  I had a clean install of 10.9, and used migration assistant to restore my settings from a Time Machine Backup. 
    The problem is that the Home folder for my user is now named "Cody 1" when it used to be "Cody".  This seems like a minor issue, but all the programs that reference data in the old location, are forcing me to go and find the data manually.  Everything from iPhoto to VirtualBox, all files have to be found manually. 
    I have tried the instructions set forth in this article, http://support.apple.com/kb/ht1428, but the dialog that should, according to the article, allow me to redirect the account to the existing folder, returns an error saying that the user name is already in use.  There is no option to use the existing folder.  I have tried re-naming the folder to something different, to no avail. 
    Ideas?
    Thanks in advance. 
    -Cody

    The Apple Support document you referenced is cumbersome, outdated, buggy, and too likely to result in the sort of problems you described.
    It may be too late now but see the following:
    Niel's post here: How to change name of home folder
    and:
    Apple Support Communities contributor Pondini found an astonishingly simple way to accomplish what you seek. etresoft distilled that information into the following User Tip:
    Changing user account short name
    Note that he writes it has been tested on Mountain Lion but the procedure appears sound and should work equally well with Mavericks.
    Back up your system before doing either one.
    To fix what happened might be possible in Single user mode. I don't have specific instructions but you should be able to find and delete user accounts in the /Users directory.
    Type carefully and don't proceed without knowing the risks.

  • How do I change the name of my "User" name?

    I bought a used Macbook Pro. I hate my Home User name and can't figure out how to change it. Let me explain. When looking at the finder window at the botom it gives a path "Macintosh HD > Users > Abc123".
    How can I change "Abc123" to a name I like?
    Using Leopard 10.5.8

    I tried it and it sort of worked but didn't do what I needed. I am trying to change the name of the home folder but keep all its settings, desktop, etc. When I used the Advanced area and changed the path name and did a restart it gave me a fresh desktop like a new computer. All my settings were wrong, etc. I guess it did the same thing as if I had created a new account name but what I want to do is just change the path name. I guess if I do that it would screw up all my file paths since they probably would not automatically update to the new path name, huh?

  • How do i change the name associated with my icloud

    how do i change the name associated with my icloud

    If you are trying to change the iCloud ID to another ID, go to System Preferences>iCloud, sign out, then sign back in with the ID you want to use.
    If you are trying to change the name of your existing iCloud ID and not trying to change to a different ID, you can change the name of the ID as explained here: http://support.apple.com/kb/HT5621.  After doing so, you'll need to sign out of the exising ID, then sign back in using the changed ID.

Maybe you are looking for

  • Creative Cloud FAQ clarity

    I'm looking for clarity about this FAQ: "Do I have to save my files to the storage space on Creative Cloud? No - just sync what you want. You can save every file to your desktop and choose which ones you sync to Creative Cloud." DOES this mean you ha

  • Trouble Shooting in Business Explorer and its Solution ....

    Hi All BW Experts, I would like to have some sample of BW Reporting issue (Data Discrepancies)and how to solve them in General including its solution. Like on Navigation Display and etc, any input is very highly regarded. Thank You in Advance Kumar

  • Cancellation of old invoice can't be post, because the juristiction code

    We change the tax juristiction code structure for Canada, according to some OSS notes. The total length were 4, now changed to be 13. However, when we cancel the old invoice created before the structure change, the cancellation invoice can't be post

  • Best SAP Security Practices Print,file,job schedule, archiving

    Hello All, i would like to know in your experience which will be the best practices for Security  for this list below: - Printer security (especially check printing) - File path security for export/import - Best Practice for Job Schedule and Spool fi

  • Massive photo upload

    Hi Guys, I found CF 'ARCHIV_CREATE_DIALOG_META' is useful for massive photo upload.I tried tat,but getting an error(file_open_error)  eventhough valid file exists. And also, -What should be the name of  photo? i kept as (emp no).jpg , - Do we need to