Rename a file PROPERLY on disk

Im trying to rename a file.. I know you're just going to tell me to use 'renameTo' but that doesnt actually change the files name on disk, it just changes to name of a 'File' object.
How do I actually change the name of a physical file on disk that can be seen in a file browser or windows explorer? PERL can do this in one line :P

well im using Ubuntu Linux and im sure I have permission to alter the files.. Id appreciate it If somebody could show me how to rename files by either linking me to a site or posting some code.. I found this example:
    // File (or directory) with old name
    File file = new File("oldname");
    // File (or directory) with new name
    File file2 = new File("newname");
    // Rename file (or directory)
    boolean success = file.renameTo(file2);
    if (!success) {
        // File was not successfully renamed
    }can somebody explain it to me? does this actually alter files on disk, or just objects you have created?
if I did the following, would it actually rename the file i have on the disk, or just the variable 'file'?
    // File (or directory) with old name
    File file = new File("C\:\\music\\oldsongname\.mp3");
    // File (or directory) with new name
    File file2 = new File("C\:\\music\\newsongname\.mp3");
    // Rename file (or directory)
    boolean success = file.renameTo(file2);
    if (!success) {
        // File was not successfully renamed
    }sorry if my backslashes are in the wrong places, but you can see what i mean

Similar Messages

  • Batch Action - Does NOT Rename Files Properly

    have CS3 on XP
    I am doing a batch rename. The batch transfers the images from folder to folder like I want and performs a reduce size to 600pix action I created...but it DOES NOT rename the files to what I tell it.
    I want the files original name to have the word "WebSize" added to the filename before the extension. I set this up in the batch. What I get is the original File names.
    Now I did Do a file "save as" in the original action because I wanted to limit final file size to 100k per jpeg file size. I checked the override...and unchecked the override...neither setting alloows the new name to be made...just the original file name.
    Can anyone help?
    Thanks
    Suzzie

    Your action doesn't to seem to include any Open actions. Why do you have the "Supress" option enabled?
    Also, since your action has the two save commands, you would just leave the Destination set to None. Setting a Destination means that is going to save the files again.
    The problem you'll run into though is that the action also saves the file name as part of the action, so that you'll end up just saving over the one file each time the action is played back on your 400 files. So Photoshop will process all the files, but each time it will overwrite the first file, so you'll end up with one file in each folder. Normally, in these situations, you'd use the Destination setting and use the "Overrride Action "Save As" Commands", which would substitute the Destination folder for whenever a Save command is used. The problem here is that you can only choose a single destination folder, so all files would be saved to the same location.
    Short of scripting this, it may be best to break this into two separate actions.

  • Renaming a file

    Please, make it possible to rename the file from within LR - in different modules, including Library and Develop.
    This can be done by adding an option "rename photo" into the right-click menu, - just next to "delete photo".

    This request is just one example that points out the confusing interface and feature set of Lightroom metadata editing.
    This entire set of tools in the interface needs to revamped. Lightroom metadata editing is badly broken.
    For instance, metadata editing simply is not built for ease-of-use or a smooth, efficient, production-oriented workflow. Pop-up lists of keywords already created should appear in the Keyword selection list when importing files. Previously created folder and file names should be visible when naming new folders and files, to help users achieve consistent naming patterns. The Lightroom team left all this to guesswork. The truth is, some good metadata editing features are included with version 1x of this software, but they've just been checklisted into the program rather than designed with a thoughtful, intuitive workflow that improves and streamlines the editing process.
    And the last time I checked, renaming files in v1.x didn't always work properly (though I have not tested this lately). i.e.: with version 1x, if a folder of image files were simply dragged from a CF card onto your hard disk instead of being imported, file renaming didn't work at all (the Lightroom database reported that the files had been renamed, but the file names on disk didn't change.
    When version 1x of the software was first released, I created and submitted a whole laundry list of metadata editing issues. I feel that correcting these should have been a priority and that they should have been fixed by now. The initial version of Lightroom metadata editing gets in the way of getting real work done. This week, I'm finally updating Alsoft DiskWarrior, and then will download and install Lightroom v1.4.1. I hope I'll see some improvements in metadata editing, but I fear Adobe will leave these critical improvements for a future release.

  • Can't RENAME a file like Windows can?

    Real easy. I just need to rename a file from this:
    A2Capital.jpg
    to this:
    a2capital.jpg
    I do this in Windows and of course every OS I have used since the 1990s at least. Why can't this be done in OS X 10.4.9?
    I am on a network drive of a Windows Server, if that makes a difference. The error I always get is
    The name a2capital with extension ".jpg" is already taken. Please choose a different name.
    Oh, come on. This is an easy one, right?
    It happens whether I click the filename or if I Show Info.
    Mac Pro Quad 3.0 Mac OS X (10.4.9) I usually run Windows XP

    OS X's filesystem, HFS+, is case-preserving, meaning
    it stores the upper and lowercase characters of
    file/folder names, however it's not case-sensitive
    (unless you specify it as such when formatting the
    disk in Disk Utility). In a case-preserving
    filesystem, MyFile, mYfILE, myfile, and MYFILE all
    reference the same file. There is no need to be rude
    to Kappy, he was just trying to help. Here's some
    reading if you want to learn more:
    http://en.wikipedia.org/wiki/HFS_Plus
    http://en.wikipedia.org/wiki/Comparisonof_filesystem
    s#fn_35
    http://en.wikipedia.org/wiki/Case-preserving
    Note: HFSX in 10.3 added the ability to format a disk
    as Case-Sensitive. If you didn't reformat your disk
    when you got your Mac, it's Case-Preserving, not
    Case-Sensitive.
    I see what you mean by case sensitive. I think Macs and Windows are similar in this regard. All that means is that if I type in a command to run, or I type a filename to launch, the OS is forgiving if I say "BLaH.JpG" for a file that is really "blah.JPG" -- if it's on the hard drive like that already.
    You bet. But in both Mac and Windows it seems, I can rename the file to whatever mixed case I want and get no errors.
    I only have this problem on the network drive,
    which like I said is a Windows 2003 Server share.
    Because your question is in the context of renaming a
    file on a remote Windows share, then all the talk of
    whether HFS is case-sensitive or not doesn't matter.
    I'm assuming the share you're connected to when
    trying to do this rename is NTFS? Macs use Samba to
    connect to Windows shares. I've never tried to do
    what you're doing through a samba share. It could be
    Samba, or it could be how you have your share set up.
    It does look like a Samba idiosyncrasy. I have used Samba before in FreeBSD (a relative to Darwin/OS X) but I would have no idea if that was the case there.
    Samba has traditionally had some oddities, bugs, and problems due to the nature of open-sourcing a Windows custom secret network system. But Macs do claim to be interoperable with other networks and systems. This can't be unusual. Lots of people need to connect to a Windows share.
    Ha, to be honest, I don't think I would even try to setup a NFS share on the Windows server, and there aren't any UNIX servers at this location.
    Who heads up the Samba stuff for Mac OS?

  • Renaming typedef file caused constants reset

    Hello!
    Here's a short description of the problem I encountered:
    I renamed the filename of the typedef that was used in my state machine for state coding (see for example State Machine template shipped with LV). As result I lost values of ALL constants that coded states in my state machine, i.e. they were reset to value of the first value in state enum.
    Note: when opening state machine that used the typedef
    I got the message something like "VI was changed in memory. Reload from disk or view from the memory?". And 2 buttons: View and Discard. I clicked "View".
    Then after restoring all constants manually, I saved my work to archive and tried to rename typedef file again, the result was the same - all constants reset to first value of enum.
    I restored files from archive, again renamed typedef file,
    then closed my app WITHOUT saving state machine that used typedef. After opening my program I got the message "Searching for my typedef", pressed "Browse..." and loaded typedef from renamed file. Constants were left without any change (uh-r-r-a!).
    Before posting this message to forum I tried to make an example to show the problem, but o-o-ps I failed to do it.
    It didn't repeat even with my program.
    This post can't be considered as bug report, as I can't repeat the problem. But I think the problem exists as I lost values of all constants after renaming typedef file, and this is the fact.
    So my advice (that old as the world) to everybody is to save work even when innocent actions are made such as renaming typedef file names.
    Probably somebody encountered this problem and knows how to repeat it.
    Thanks for attention.
    Any comments appreciated.
    Rashid.
    Using LV 8.0 (LV Run Time Engine 8.0.1) on Win XP with Russian locale, all VIs used in my programs have names in cyrillic sometimes mixed with english letters, e.g. "russian name (typedef).ctl".

    Hello, Charlie,
    I can say absolutely sure that I always used LabView to rename my typedef file. I never use Windows Explorer to rename typedef files (or any other LV files) in my practice.
    Besides, when the values of my constants were reset there wasn't any broken wires. The block diagram wasn't corrupted. Everything was fine except default values of my constants. Due to that I noticed this error a little later - after renaming typedef file I ran my program and couldn't understand why it fails to act as should. When debugging this problem I went down to my state machine and only then I saw that all my state constants are reset to default values.
    I never used "Substitute copy for original". I used only
    "Rename" when renaming my typedef file.
    I didn't add any items to my typedef. The only things I did are:
    - renaming my typedef enum label in the *.ctl file;
    - and "Save as.." -> "Rename..." - renaming my typedef file.
    Besides, when I did try renaming 2nd time to reproduce such behaviour: I left typedef enum label without change and the behaviour was the same.
    So, such behaviour (loosing constant values) I get TWO times.
    But after I worked around this (see 1st post) I couldn't already reproduce this behaviour.
    If I'll succeed in this one more time again, and be able to reproduce this behaviour, I'll certainly post to you my steps.
    Thanks for attention.
    Rashid.
    P.S.
    1. As to broken wires if I get it right - in your case you added new items to typedef but your case structure in state machine was not updated to contain new states handlers. If so, then it's obvious why you got broken wires. But as I didn't change the typedef itself (only renamed it), I didn't get broken wires.
    2. I wouldn't be surprised if I'd have done something in the weird way: I mean renaming by Explorer or saving, closing and so on. I was doing everything from the LabView environment. As far as I remember I didn't rename the state machine vi file at that, only typedef file. And my state machine was always opened. The only file I was opening/renaming/closing was typedef file. And as far as I remember I opened it by "File -> Open..." and not right-clicking at constant and "Open TypeDef..".
    3. I understand that my description is foggy :-) and that it's difficult to find this weird set of steps, but who knows. Anyway I appreciate your help.Message Edited by Rashid on 06-13-2006 12:03 PM

  • Batch Rename Multiple files with different names

    Hi,
    Is there any way to batch rename multiple files with individual names? I.e
    IMG_123 changed to  RSP45AS
    IMG_124 changed to MOL157A
    IMG_125 changed to AGKH135
    IMG_126 changed to MNOLH13
    IMG_127 changed to ASFBLUG
    Etc.
    Are they any programs or scripts or plug ins that would do that job?
    Thanks

    HI there Onemorewave,
    It looks like there is a batch remname feature included in OS X 10.10 Yosimte if you are planing on updating. 
    Rename files, folders, and disks - Mac Help
    Rename multiple items
    Select the items, then Control-click one of them.
    In the shortcut menu, select Rename Items.
    In the pop-up menu below Rename Folder Items, choose to replace text in the names, add text to the names, or change the name format.
    Replace text: Enter the text you want to remove in the Find field, then enter the text you want to add in the “Replace with” field.
    Add text: Enter the text to you want to add in the field, then choose to add the text before or after the current name.
    Format: Choose a name format for the files, then choose to put the index, counter, or date before or after the name. Enter a name in the Custom Format field, then enter the number you want to start with.
    Click Rename.
    Note: To batch rename, you would want to choose the "Format" option.
    -Griff W

  • Help! iPad 2 showing NEF/RAW files as 'local disk' ?!

    Hi all. I really hope someone can help as this is doing my nut in!
    I've always used the camera connection kit with my iPad 2 and Nikon D700 before with no problems. I can transfer the RAW/NEF files from my camera to my iPad 2, and then when I get home I can simply copy the RAW files to my PC by connecting the iPad via USB, browsing for the NEF files and copying.
    I've just returned from holiday and tried to do the same, but my NEF/RAW files from this trip are showing up as 'local disk' as shown here:
    They are definitely the RAW files, as when I right click on their properties they are about 13-14 MB in size which is about right. The properties box shows the file types as 'Local Disk'. If I try to copy the file on to my PC (Windows 7 Home Premium), it says there is an unexpected error (0x00000000) that keeps me from copying the file.
    I can't rename the file to .nef or anything.
    Previous RAW files from other holidays that are stored on the iPad2 still show as NEF/RAW and I can copy them to my PC with no probs. It's just this recent transfer from Camera to iPad has buggered all the files.
    If anyone knows of a remedy to somehow rescue these RAW files or let my PC be able to read/copy them I'd be much appreciative.
    Many thanks for your help in advance, and for reading.

    1.) Which of the two is the visible one in Library mode? can one set the preference?
    Raw only. The jpeg is sort of like sidecar. Cannot set a preference. The only setting you can change is to view them separately.
    2.) Which is edited?
    Raw only.
    ... and at the same time I feel I need to be able to compare them.
    Lightroom's Canon-specific DNG profiles are developed to match Canon's picture styles (or whatever they are called). So, if you use, say, the Faithful Picture style in Camera, Lightroom's "Camera Faithful" profile will render your raws very close to DPP, if not identical. That's for default settings. However when you start adjusting, Lightroom's and DPP's processing may differ.
    You may not even need those Jpegs for comparison, after all.

  • Question from renaming a file and copy a file

    Hi
    Like I tell in subject I have a question about those 2 functions.
    Well I have a program that will copy files to an other directory for backup. Those files can have so to 1GB. Well I wrote a my code on using FileChannel and that takes some good time to copy it to the other place.
    But then I tried just for fun something different like renaming the file to that path. For example:
    Orignal File: file.db <-- +- 1GB same directory as the jar file
    to renamed file: ../../../test/file.db
    That goes very fast and I can open the file without lost of data.
    But what is the difference between both function because they do the same just that rename is much faster.
    Thx in adavance for your help

    But what is the difference between both function
    because they do the same just that rename is much
    faster.Copying a file involves copying all the data of the file from one physical location on the disk to another. That involves a good deal of IO.
    Renaming/moving a file is usually implemented on platforms in such a way that the data remains at the same location and file table entry is modified.

  • How to properly create disk iimages using Disk Utility?

    Can some one help explain how to properly use Disk Utility? When making an image of a CD, should I click on the CD drive and click on NEW IMAGE, or should I click on the mount name, which is indicate just beneath the CD drive?
    Thanks!

    "read only" means just that that the disk image is read only and you can't add files to it once the disk image is mounted. but as I said, if you want to make a backup of the original CD then you have to choose "CD/DVD master". then, when you burn the disk image to a blank CD it will be formatted properly.

  • Renaming .mov file corrupts data

    Recently I used Data Rescue 2 to recover my external HDD data after an accidental partition. The result was that Data Rescue 2 found all of the video files and marked them with a generic file name in a numbered sequence. Eg: QT0023.mov, QT0024.mov ect. These files play fine in Quicktime, and once imported to iTunes also play properly. The problem is, when I rename the files in iTunes to the proper titles, the file becomes unplayable in both iTunes and by Quicktime. Quicktime reports that the file is not a movie file, while iTunes gives no error.
    Anyone?

    etnadan wrote:
    Hello
    I have one folder with several mov files each with a different name.
    I also have 2 text files in the same folder.
    ORIGINAL.txt file with the current mov filename in the folder.
    RENAME.txt file with the replace names for each file.
    Is the only content in the file the names?  Are the files actually named ORIGINAL.txt and RENAME.txt?
    In Terminal, if you enter: cat RENAME.txt, do  you get the new filename?

  • Incremential Backup & renaming/moving files

    Hi!
    I guess usually, when an incremental backup is done, a moved or renamed file will be treated exactly as two different files - one that has been deleted somewhere, and a new one somewhere else, resulting in an "additional copy" of the file and the loss of the traffic & disk-space?
    If so: Is there a solution, that actually just links the moved files trough different backup stages instead instead of initiating another "transfer/copy" and keeping different copies of the same file? Or something like that?
    Or in general: Which backup solution might be a good one to get into, if moving/renaming big files is common? What man-pages will I most likely want to read and what words to google to be able to make the right "decision"?
    Thanks!

    Mmmh... something like...
    1) make list of "deleted on source" and "new on source" files just like I guess rsync etc. do too at some point
    1a) optionally drop files with filesize smaller than X from list
    2) look if a distinct "new" (source) file has same file-size as a "deleted" (old backup) one / match up
    3) compare md5 for files that match (again source <=> old backup)
    4) link finds from old backup to new increment backup instead of copying from source
    Am I missing something? Maybe I just can't wrap my brain around that one to see the real problem...

  • Copy a file from hard disk to a jar

    Is there any way to copy a file from hard disk to a jar file?

    hajani wrote:
    No, I want to copy a file into an other jar file (like a zip or a rar file)
    Edited by: hajani on Dec 7, 2008 4:11 AMIf you really do mean 'jar' file an not 'zip' or 'rar' then you can use class java.util.jar.JarFile and write your own code. If you don't feel like writing a load of code then and you can guarantee that the 'jar' executable is going to be available then you could use Runtime.exec() or it's cousin ProcessBuilder. If you mean a 'zip' file then you could use class java.util.zip.ZipFile and write a load of code. If you mean a 'rar' file then you will either have to find a 'rar' class library or again use Runtime.exec().

  • HT3775 I have a bunch of .MOD files I cannot play from our Canon video cam. I tried renaming the files as MPEG or MOV, I get the message "The document "001.MPEG" could not be opened. A required codec isn't available." Any advice on getting these to play?

    I have a slew of .MOD files I cannot play from our Canon video cam. I tried renaming the files as MPEG or MOV, I get the message "The document “001.MPEG” could not be opened. A required codec isn't available." Any advice on getting these to play? Thanks!

    Try installing Perian or VLC. Some AVIs require a codec which simply isn't available for Mac OS X.
    (85018)

  • Web.show_document calling .htm files saved on disk....

    Hi ,
    Is it possible to call .htm files saved on disk - let's say c:\my_htmFiles on AppServer/DevSuiteServer using the web.show_document form's built-in...????
    I have tried the following:
    web.show_document('c:\my_htmfiles\first.htm','_blank') and
    web.show_document('file://c:\my_htmfiles\first.htm','_blank')
    but whereas in the web browser's file->open both of them work.... in web.show_document do not....
    Is it possible to do it....?????
    Note: I use Dev10g
    Thanks....
    Sim

    I 'll try it of course.... but is it possible to define multiple directories down this virtual directory.....????
    Assuming that there is the following dir structure:
    C:\dev10gr2/tools/web/html
           |
           |--------------------------------------------/app1
                                                         |---------------/subdir1
                                                         |---------------/subdir2
           |--------------------------------------------/app2
           |--------------------------------------------/app3Is it possible to define multiple dirs ....????
    Is there any doc which describes it with examples.....?????
    Thanks.......
    Sim

  • I want to remove what Skype identifies as "Tell you friends what you are feeling . . . ."  One person on the Skype community said I could rename a file, but he thought I was on a PC.  I am using OS10.7.4, and Skype is functioning OK.

    One person on the Skype community suggested: 
    Re: disable mood history
    17-09-2011   02:04                 
    Actually it is possible to delete your own mood message updates but it requires an unsupported ”fix”.
    You need to delete the keyval.db database file. In order to be on the safe side, it’s best just to rename this file, so you can always get it back if something went wrong.
    You can find this file by entering %appdata%\skype in the Start Run/Search box. This will open the Skype User folder. Locate there the folder with your Skype Account name and the keyval.db file will be there. You must stop Skype from running on your computer before deleting/renaming this file. Next time you start Skype a new version of this file will be recreated and all mood message updates will be removed from the home page.
    However, this guy didn't know I was on a Mac.  I phoned Apple to see if they could show me how to get into the Skype file apparently on my computer, and they couldn't find it. 
    Anyone out there have any ideas?  It doesn't seem as if I have any Skype files on my computer.  If I need to make file changes via "the terminal," can someone tell me how to do this?
    Gretchen

    Hello,
    I had the same problem with finding this file.
    There's no such file in Mac OS X version of Skype. But there's a directory for your Skype user account in /Users/%current_user_name%/Library/Application Support/Skype/
    try:
    quitting Skype
    renaming old folder
    signing into the Skype

Maybe you are looking for

  • Ipod is frozen on do not disconnect screen....

    i seriously don't know what to do with m ipod anymore. it's a 5 gen ipod video that i've had for less than a year. today i tried to sync it to my computer which is a sony vaio with windows xp and it got stuck on the do not disconnect screen. i plugge

  • No connection between computer and ipod?

    I am having trouble downloading itunes to my ipod.  The ipod makes a connection but does not show anything.

  • Can anybody explain me about this formula???

    Hi, Can Somebody explain me what this formula means? ( 'Posting Period' >= 1 ) * 'Jan - Actual (CY)' + ( 'Posting Period' < 1 ) * 'Jan - Forecast (CY)' Thanks

  • To dispaly Workflow diagram in apex

    Hi all, I am using Application Express 4.0.1.00.03 with 10g. My requirement is to display Workflow diagram in EBS on Apex. Is it possible... thanks in advance...

  • Flash Builder Won't Open

    When I click on the Flash Builder application, the program brings up the loading screen. However, after a few minutes, the loading screen disappears and that's it. I checked my task manager and the program isn't open. So, what's going on? I even trie