Renaming files on OSX problem

I hope someone can help me with this problem fairly quickly. It seems to be pretty simple, just that I'm missing something fundamental here.

Here is my code to iterate through some layers (in the to lyrs), dupe the document, filling in the active layer and save as PNG.

// Hide all layers, then loop thru them, trim/crop and save to disk
for (var i in lyrs){


    // Set active layer and duplicate doc
    activeDocument.activeLayer = lyrs[i];
    activeDocument.duplicate();


    // Turn on layer/set visibility
    activeDocument.activeLayer.visible = true;
    if (activeDocument.activeLayer.parent != activeDocument){
        activeDocument.activeLayer.parent.visible = true;
    }


    // Trim to layer bounds, export file, close duped doc, etc...
    activeDocument.trim(TrimType.TRANSPARENT, true, true, true, true);
    file = File( filePath + "//temp.png" ); // setting temp name
    activeDocument.exportDocument( new File(file), ExportType.SAVEFORWEB, pngOptions );
    activeDocument.close(SaveOptions.DONOTSAVECHANGES);


    // Fix path if last character isn't a front or backslash
    if ( !((filePath.match(/.$/) == "/") || (filePath.match(/.$/) == "\\")) ){
        filePath = filePath += "\\";
    }


    // Two errors here!
    // Windows: File.rename() doesn't overwrite existing file
    // OSX: File.rename() doesn't take place at all - so for each iteration in the loop we only write out the temp file
    alert("2) renaming: \n" + file + "\nTO:\n" + filePath + lyrs[i].name + ".png"); // Confirms correct paths!
    file.rename(filePath + lyrs[i].name + ".png"); // Avoids the hyphens -error with Safe for Web


    activeDocument.activeLayer.visible = false;
}

The problem is when I try to rename. OSX happens, even if the paths seem to be right (I checked with alerts) and I do not understand why that this code works very well under Windows.
The second question that I spotted at least windows (prob even on OSX) is that File.rename () does not work if the file already exists. Y at - there no flag without papers or something that can allow him to do? Or do I have to check for the file and delete it manually? (does not seem necessary!)

Help is appreciated!

A problem has been resolved:
File.Rename () works differently on OSX - you must provide the name of the file ONLY. Provide a complete path will not work.

Number two still needs fixing. I still have the problem with rename() works only if the file exists.

Tags: Photoshop

Similar Questions

  • Rename files in Lightroom 3 when importing (problems)

    I can trouble importing files into Lightroom name where I want to custom their name - sequentially. I import the data to a folder on my hard drive in the folder that contains all of my files in lightroom. I am able to import and rename files in folders with ease. Others said Lightroom 3 couldn't have their name. Why? If I try to import and rename in LR2 I have no problem. I'm basically a Nikon generated file, say DSC0001. NAVE and rename in Ireland 07-30 - 08.NEF. Lightroom 3 cannot do. Anyone know why? Thank you.

    I'm renaming all my during the import of the NAVE.

    Here's how:

    and it works very well.

    There is another problem with the import you might encounter. The actual files on the file system and records, he presents in the library do not correspond regarding the rental structure. Try to pass will result in an error message that the file cannot be moved because it is already there. If you run this as well, just let me know for a solution. Hope that Adobe fixes this annoying very quickly.

    Franz

  • File navigation on OSX problem - how to use a filter function?

    I work with file navigation atm using the JSX file objects and the openDlg method and quite frankly, it drives me crazy.

    He has a crazy person decided it was a good idea to have the filter flag on the totally different openDlg method to Win and OSX? Under windows, you use a string for filtering, OSX he wants is a function!

    I checked the documentation and also searched this forum and I can't even find an example of how to set up so that it works for Windows and OSX?

    OK, so I found the syntax, but it still does not make sense.

    fileMask = function(file){file.name.match(/\.psd$/i) ? true:false;}
    


    Here we have the psd extension hardcoded in the regular extension. But what happens if we want it to be a variable? And what happens if t he file does not yet exist.

    Basically I want is the user of:
    Navigate to a folder

    Set a file name

    record.

    The extension type must be locked!

    Compared to the way of windows to do things, the way OSX to use a filtering function is too complex, absurd and downright annoying!

    EDIT: I also discovered that you can not write a file on OSX name unless the file already exists. Come on! Is this the type of dialogue hurt or something?

    Here is my script to request a file that handles the differences Win/Mac

    function isWindows() {
      return app.systemInformation.indexOf("Operating System: Windows") >= 0
    }
    function isMac() {
      return app.systemInformation.indexOf("Operating System: Mac") >= 0
    }
    function promptFile(filter_extension) {
      var filter = null
      if (isMac()) {
           if (filter_extension) {
                var filter_regex = new RegExp("[^\.]*\."+filter_extension+"$")
                filter = function (file_entry) {
                     return filter_regex.test(file_entry.name)
                }
           } else {
                filter = function () { return true }
           }
      } else if (isWindows()) {
           if (filter_extension) {
                filter = filter_extension.charAt(0).toUpperCase() + filter_extension.slice(1)+"-files:*."+filter_extension
           } else {
                filter = "All files:*.*"
           }
      } else {
           filter = null
      }
      var f = File.openDialog("Select your file", filter, false)
      if (f) {
           return f.fsName.replace(/\\/g, "/") // sanitize to forward slash
      }
    }
    }
    
  • Finder Bug El Capitan - rename files

    Behavior: Rename a file in a Finder window, while the file is renamed, is always in peak mode (but now has a new name) click on the following to rename file. Finder changes the current selected file of this second return to the file you previously renamed (and moves it to the new position in the Finder window according to the sorting option).

    Expected: Rename a file in a Finder window, while the file is renamed is always climax with its new name mode, click on an adjacent to rename file. This file must be selected although Finder/Apple IOS runs in the background to rename the previously selected file and put it in its correct position in the window.  This should result is the way in which previous versions of OSX worked. He always behave this way IF you change the name of the file in a search window that results.

    As someone who renames the files frequently, this "jump" of the file highlighted is tedious and boring. I thought that it would have been fixed a long time ago when El Capitan is out - pretty sure I did mention to him at the time, too. As I am not a programmer, I can't access system to report bugs to Apple.

    Users which rename files quickly (where batch renaming is not applicable) should not experience the selection of active file exchange once they click on the next file to be renamed - the first file renamed should run in the background to reposition themselves in the Finder window.

    10.11.4 version (still has this glitch)

    If the files are sorted in the order of alpha this is normal behavior as far as I remember, unless the new name does not change the file command in the sort list. In addition, if you rename a file, then the file is more in highlight mode. You may need to try a renommeur files instead. This is feasible if you similar changes in each file as a sequence of numbers or changing one extension to the other as a photographer can. Or just use a sort column where the order will not change when you change the file name, size of the kind.

  • Press back twice to rename files?

    On my MacBook Pro (mid 2015 running 10.11.4) I have to press the return key twice when a file or folder is selected in the Finder in order to be able to change its name. The first time I press return has absolutely no effect or action. I think it is a particular behavior, I've not met in any of my other machines and I don't know how to change it. Any ideas?

    Hello, SonathD.

    It seems that you are having problems with your Finder not allowing you to rename a file or folder by using the return key after choosing, he. You are right in your expectations of the process of change of name, as shown in this Knowledge Base article:

    OS X El Capitan: rename files, folders, and disks

    You can change the default name of most of the files, folders and disks, including the internal hard drive (named Macintosh HD). If you change the name of your hard drive, it always appears with its original on a network name.

    Rename an item

    1. Select the item in a window in the Finder or on the desktop, press return. Or force click on the name of the element.

    2. Enter a new name.

      You can use numbers and most of the symbols. You cannot include a colon (:)) or start the name with a dot (.).) Some applications may not allow you to use a slash (/) in a file name.

    3. Press return.

    For further troubleshooting, you can test this behavior to another user to determine if your problem is specific to the user or the system-wide. This article provides a great tutorial on how to do:

    How to test a question in another account on your Mac.

    Before you try a different user account

    If you see unexpected behavior on your Mac to first try the following steps:

    Try to search the base knowledge of Apple for the specific symptom or an alert message you see. There could be more simple measures that you can take to solve the problem.

    Try to boot your Mac in Mode safe. Restart your computer. Hold the SHIFT key when you hear the startup sound. Release the SHIFT key when you see the Apple logo appears. Your Mac starts up in Safe Mode. Safe mode performs a check of your startup disk directory and removes data from the cache. Once your finished Mac commissioning, restart the Mac normally (without hold the SHIFT key) and see if the problem is resolved.

    Make sure your software is up-to-date. The question that you see can be addressed by installing the available updates.

    Check to see where the problem occurs. If a problem arises until you see your desktop, it is less likely that it is related to a setting or a user account. If a problem occurs with a Web site, see if the pages of other websites correctly first load. There could be a problem with the site and not your Mac.

    How to test with another user account

    You can find out if unexpected behavior is related to the user file or a parameter in trying to reproduce the problem to a different user account. This process includes creating a new user account, connect to it and test for the issue.

    Create a test user account

    1. In the Apple menu, choose System Preferences.
    2. Click the users and groups in the System Preferences window.
    3. Click the lock icon and enter an administrator name and password.
    4. Click on the button Add (+) below the list of users.
    5. Choose a type of user in the new pop-up menu.
    6. Give the user a name and first name, account name, and password.
    7. Click OK.
    8. Close the System Preferences window.

    If there are documents from your user account that you want to test with original, place a copy of these items in the shared folder in the users folder. Press the Option key while dragging a file in this folder to create a copy.

    Connect to the test user account

    Log out of your current user account by choosing logout in the Apple menu, and then open a session the new account that you created. If you are prompted to login with your iCloud or Apple ID account when you log in, skip this step.

    Try to reproduce the problem

    Try the same steps that caused the unexpected behavior to appear. For example, if you are unable to print, try printing from this user account. If you were unable to connect to the Internet, try to navigate on a website of this user account.

    If you use specific test settings depends on (for example using a specific e-mail account or an account iCloud) implemented the same test user account. For email and other parameters, you can use the Internet accounts pane in system preferences to set up these types of accounts. If your home folder files are necessary for tests, copy them into the shared folder in the users folder (/ Users/Shared). After you connect as a user test, copy these items to the same location in the test user home folder to test with.

    If a problem occurs in account only one user

    Is using the same steps in a user account test does not cause the same unexpected behavior, most likely you don't need to reinstall applications or OS X.

    • If a problem occurs only in a single application, check the documentation or Web site for instructions on troubleshooting specific preferences or the definition of the application files.
    • If you need help with a problem or a specific alert message, search the Apple support Web site for the text of the alert message you see.

    If a problem occurs in more than one user account

    If the same unexpected behavior occurs in more than one user account on your Mac, try checking for software or hardware problems.

    Once you have finished

    When you are finished testing, disconnect from the test account by choosing logout in the Apple menu. Then, connect to your original user account.

    You can Remove the account to test user created when you are finished. Make sure you're completely finished stable, and you don't need the files or settings you have created or copied there until you delete it.

    Get help

    If you need assistance with a problem software or hardware, Please contact Apple technical support. If you are working with a consultant, engineering or service provider to resolve a problem, remember to mention all the steps you have already tried and the results. Also mention the alert messages that you saw in the context of the question. You can take a screenshot of all the messages that appear to refer to it later.

    Thank you for reaching out to the communities of Apple Support.

    Kind regards.

  • I can't rename files or folders in my 'downloads '.

    I'm unable to rename files or folders from my "Downloads" folder I ran various scans and a folder of the Microsoft fix it tool, but it came in fine. No error message, it just rename after I type the new name and press ENTER. I also checked that I have the folder owner and I am the only administrator (principal).

    I have to move the files to another location, rename them and get them back. I can't find anything on this error anywhere else.

    I found someone else who has this problem in 2011 with no resolution:

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-files/unable-to-rename-folders-reverts-back-to-the/e754de3b-58bf-4bf5-B168-416deed1aea1

    I use Windows 7 64-bit.

    Why are you pressing on enter?

    Right-click on the file, rename. and move your mouse. That's all.

  • Satellite L630 - how to rename files or folder in the Start Menu

    I used to rename files and folders by clicking the right button of the mouse or touchpad set and choose Rename.
    With my new Satellite L630, if I click on the right button, the menu with the options does not appear.

    It does not appear when I right-click on ay other file or folder, but not in the start menu. I can also drag an item any within the start menu.
    So I can not at all to customize (already tried with F2, does not or)

    What should I do to rename, drag the items from the start menu?

    Thank you for your kind contributions,
    Walter

    Hi mate

    I assume you are using Win7. Right?

    Cannot rename files (programs) that appear in the Start Menu.

    You can ONLY rename folders.
    If you click on all programs, then you should also see some folders there.
    Right click on the folder and you should see the option rename.
    Choose this option and then you should be able to rename the folder

  • Windows that display progress on delete, move, or rename files remain open

    Original title: remove the window remains open.

    Windows Vista indicate the status on deletion, move, or rename files remain open, even if the operations are completed. I have to shut them down in the Task Manager.  All the patches?  Thank you.

    Hi bobes42,

    See the article next to the Intel site:

    http://www.intel.com/support/motherboards/server/s3000ah/sb/CS-023697.htm?wapkw=(Intel+Matrix+Storage)

    I hope this helps!

  • I have to remove the duplicate files, but having problems by selecting more than one file in the player at the time.

    I have to remove the duplicate files, but having problems by selecting more than one file in the player at the time. How can I select multiple files at the same time so I can just delete them. I used to be able to do this in previous versions of Media Player, but this function seems now blocked or unavailable. The problem is this: through previous use of media player, it plays all my multimedia files several times whenever a device support has been added. He would try to save the files on my main drive, but since there is not enough room this would save the files somewhere else. This happened several times, I suppose, because when I upgraded my computer and a media scan was conducted he found duplicates of all my media various times of at least 6-8. I've consolidated since my plates on 3-disc multi to, but have now records duplicated hundreds and thousands of duplicate media files. Previous versions of Media Player would allow me to select all files and then delete them both of the reader, but also from my hard drive. So now I'm stuck with more than 300 GB of duplicate media I have to search line by line through all my hard drives to find each duplicate both, unless I can get media player to do what it can. Any help in this area would be appreciated.

    Hello

    1. did you of recent changes on the computer?

    2. is Windows media player files in double creation during playback of music files?

    To delete duplicate entries, click on another feature tab in the drive (for example the current playback), and then click library.

    If this does not remove duplicates from your library, you can use the Add to library dialog box to search computer to analyze a file on your computer the duplicate entries not valid-pointing. The player will remove invalid entries in your library that point to files that no longer exist in the folder.

    Complete the steps above for files that are stored in the hard disks.

    Method 1: Use the add to Library dialog box search for computers

    (a) start Windows Media Player.

    (b) press F3 on your keyboard to open Add to the library of the find computers dialog box.

    (c) click the Browse button to locate the folder on your computer so that your library contains invalid entries. Specify the location of the folder in the box look in.

    If you are not sure what duplicate in your library entry is not valid, you can add a path column to display in your library. Specify the folder on your computer that corresponds to the path not valid file displayed in your library.

    (d) click on the Search button.

    The player will search for digital media files and playlists in the folder that you specify and remove invalid entries in your library that point to files that no longer exist in the folder. If not valid in double entries point to other folders on your computer, repeat this procedure, specify a different folder every time.

    If only a small number of duplicate entries exist, you can delete those invalid manually by right-clicking on the invalid entry, and then clicking Delete .

    For large double-number of entries in your library (or if all your library is duplicated), it might be better to create a new library and delete the files.

    Method 2:

    After you remove the duplicate entries, run the troubleshooting of Windows Media Library settings to solve this problem.

    Open the troubleshooter in Windows Media Library

    http://Windows.Microsoft.com/en-us/Windows7/open-the-Windows-Media-Player-library-Troubleshooter

    Let us know the results.

    I hope this helps.

  • Rename files in sequential order

    original title: numbering of sequential files

    After spending many hours of editing and sorting photos from a recent trip I want to bring to a treatment for printing shop in a local photo book. Unfortunately their software performs a sort on the date modified date taken so they are out of use. I well I could work around this by renaming the files with sequential numbers, so every selected and renamed and it have been renamed as follows
    Europe (1)
    Europe (2)...
    ... europe (10)...
    .. .eourope (100)...

    Unfortunately the software in machine shops treats these numbers as text rearranges so files (when they are sorted by name) as follows
    Europe (1)
    Europe (10)
    Europe (100)
    Europe (2)
    Europe (20)
    Europe (200), etc., in other words, they are still didn't stop.

    Question: How can I rename files window "europe (001), europe (002)... europe (010)... etc (100) in europe?

    Hello

    I would suggest trying the following steps and check.

    Select all photos by pressing keys CTRL + A , right click on the first picture and then select Rename

    Type a name for the Group - space - .jpg (10001)

    for example: group name (10001) .jpg

    Press ENTER.

    Windows should rename the remaining files as follows:

    Group name (10001) .jpg
    Group name (10002) .jpg
    Group name (10003) .jpg

    For reference:

    Organize, sort, or group your files

     http://Windows.Microsoft.com/is-is/Windows7/arrange-sort-or-group-your-files

    Rename a file

    http://Windows.Microsoft.com/en-us/Windows7/rename-a-file

    Hope this information is useful.

  • Cannot access the renamed files

    Question.jpgFor the last 2 days I tried to use the bridge to rename my files. I did exactly the same way for a long time. Since yesterday, it renames them but converts the files into a sort of file I can't open or work with. Help, please. I'm desperate.

    Clearly, something was wrong with the file extensions.

    Perhaps, you can rename them again by not to rename file name, but by adding the correct extension.

  • I am new to Muse, so I am following the tutorial for coffee of Katie.  I downloaded the sample files.  The problem is not that all the files in the folder as in the tutorial.  The color swatch for example is not there.  The updated CC on the road Katies.m

    I am new to Muse, so I am following the tutorial for coffee of Katie.  I downloaded the sample files.  The problem is not that all the files in the folder as in the tutorial.  The color swatch for example is not there.  The CC file to get started Katies.mulib is also not if you can't automatically download all the necessary files.  Can anyone help?

    found in another area

    Where can I find updated cc enroute Katies.mulib file?

  • Error downloading Photoshop element 12: Arvato Berthelman - Download Manager error - unfortunately, there is a problem with the link to that file. This problem may be due to the number of users trying to download

    Error message when downloading Photoshop element 12: (I bought the license in a store)

    Berthelman arvato-

    Download Manager error-

    Unfortunately, there is a problem with the link to that file. This problem may be due the number of users trying to download the file, or the product may no longer be available. Please as minutes of a few in. If this privilege is still not available, please contact customer service at the address [email protected] or number 604-915-5200

    == > Les DEUX @ and phone number are fake!

    Hi Mireille56,

    The place where you are trying to download the software.

    [email protected] is not an email from Adobe Support.

    Please try to download Photoshop elements 12 of: http://www.adobe.com/cfusion/tdrc/index.cfm?product=photoshop_elements&loc=us&sdid=ZPQM

    Kind regards

    Rave

    < translated="" via="" google="">

    Hi Mireille56,

    Where you are trying to download the software.

    [email protected] is not an Adobe support email.

    Please try to download Photoshop elements 12 from: http://www.adobe.com/cfusion/tdrc/index.cfm?product=photoshop_elements&loc=us&sdid=ZPQM

    Kind regards

    Rave

  • Rename files using find and replace

    Is it possible to rename the files in LR CC to aid search and replace? For example, I would like to rename all selected photos by replacing the IMG_ by ABC_ string. It is such a basic need that I can't believe that LR does not support.

    LR filename + original number would almost be an acceptable substitute, but it fails if the file name is IMG_9999_HDR because Adobe assumes that the number of original file is always the last string in the name of the file and fails to find the number if is not at the end.

    Hi Bazsl,

    You may also want to consider

    FileRenamer

    This is a plugin that is dedicated only to rename files in Lightroom and free.

    Rob

  • Option to rename files on import n LR 4.3

    Hello

    I am new to LR4 and watch the tutorial video, I noticed that the option to rename the files during the import seems to be missing?  Or am I missing something?  Thank you.

    Concerning

    Anthony.

    The option to rename files is missing when you select up in the center of the import dialog box.

    is for importing the photos that are already on the drive hard and you don't want to change their location or their name. Import you "such what."

    is for importing the photos that are already on the disk hard but you want to change their name, their location, or both.

    is for importing photos from camera or a memory card.

    Renaming files is available only when you choose or .

    It is the same for the other options: and .

Maybe you are looking for

  • Firefox v 9 &amp; 10 crash immediately start up on newly installed win7 x 64

    yesterday, I installed win 7 sp1 x 64 business on my hp probook 4520 s and almost the first app that I installed was FF and TB v9 v9two of them crashes immediately when you click on them and apps and even safe mode and controls profile, that both are

  • HP 50 g: help a friend HP 50 G says he need map GB SD a1 by the Cal can find only 4 GB

    Hello everyone, I have a friend in Saudi Arabia, who just bought a new HP 50 G, it is tring to find an SD card for it. He says he must have a 1 GB card, but I though it would use what is the maximum size, though i read before HP it wasn't size max th

  • FOR SE PASSWORD BY E-MAIL

    How can I find out my password for my email, it's if for a long time that I have to plug in, I forgot? anyone? thnx a lot!

  • Can this laptop it run tf2?

    I'm thinking on Getting A HP Pavilion dm1-4010us for my birthday, but I Want it to run Team Fortress 2 on It. I don't know if they are better or worse for the minimum requirements. I just want to know, this computer it will work? Here is the Info: Sc

  • Compaq presario system recovery

    I did a recovery of the system about 3 weeks ago and although I managed to install all the parameters of my return, I have problems with the updates of windows XP. Before the resumption, I have SP3, but after recovery there was SP2, I tried to instal