File.renameTo(File) doesn't change dirs on Linux?!

Hi All,
I'm trying to change a file's name and directory with File.renameTo but it doesn't work. It says in the manual that changing dirs is O/S dependent, so i guess it doesn't work on Linux.
Is it correct? if so, what can be done to change a file's name and directory?
File oldFile = new File(filePath);
oldFile.delete();   // Delete old file
File newFile = new File(newFilePath);     // This is the new file
File tempFile = new File(filePath);          // Get name to renameTo
newFile.renameTo(tempFile)                  // Try to rename

Hmm, it worked for me, though I didn't try deleting the oldFile. A simple move from one directory to another was not problem, though. The rename would fail if the delete failed. You might check that.

Similar Messages

  • Why the html file doesn't change with applet ?

    i am new to java , i get a problem when i am modifying a applet . i recompile it to .class file but did not change its name . and the .html file which use the applet doesn't change with it , it still shows the original style , even when i delete the .class file . it works until i changed the name of the source file and use the different .class file in html . it's troublesome if i need to modify the source file because i must change the name to get it . can you tell me why and how could i avoid this ?

    I am new also & had a similar experience.
    In my case it was aftercompiling and trying to refresh the browser to get it to display the new version of my applet. I got around this by holding Ctrl down and pressing F5 to refresh.
    Also, some of the systems at university cause exactly the problem you describe. Not sure why it should work but we overcame it by placing our files in the JDK folder on those systems & it worked properly. May be worth a try.

  • File name doesn't change in Quicktime or iTunes even though i changed it in Finder

    I've have been trying to change the name of a video file (.MP4). I change the file name in the finder and it stays that way. However when i open the file in quicktime the name has not changed in the title bar. Also if i move the file to iTunes, I have it setup to copy and organize my files that i add, it changes it back to the old file name. I have all copies of the file closed. Both Quicktime and iTunes are closed. Please help me fix this. Thank you.

    You need to use a program such as VLC or Flip4Mac to play them or Switch to convert them. Just changing a file's extension doesn't change its format.
    (109393)

  • [SOLVED] Mysql doesn't start, Can't change dir to '/var/lib/mysql/'

    My mysql install was working fine but now it doesn't start
    $ mysqld --verbose
    121202 22:41:34 [Warning] Can't create test file /var/lib/mysql/home.lower-test
    121202 22:41:34 [Warning] Can't create test file /var/lib/mysql/home.lower-test
    mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
    121202 22:41:34 [ERROR] Aborting
    121202 22:41:34 [Note] mysqld: Shutdown complete
    I checked using mysql_safe & it seems to be a permission issue
    $ mysqld_safe --user=mysql
    121202 22:45:34 mysqld_safe Logging to '/var/lib/mysql/home.err'.
    121202 22:45:35 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    /usr/bin/mysqld_safe: line 107: /var/lib/mysql/home.err: Permission denied
    rm: cannot remove ‘/var/run/mysqld/mysqld.sock’: Permission denied
    rm: cannot remove ‘/var/lib/mysql/home.pid’: Permission denied
    /usr/bin/mysqld_safe: line 144: /var/lib/mysql/home.err: Permission denied
    121202 22:45:35 mysqld_safe mysqld from pid file /var/lib/mysql/home.pid ended
    /usr/bin/mysqld_safe: line 107: /var/lib/mysql/home.err: Permission denied
    But the thing is /var/lib/mysql is already owned by mysql,
    $ ls -la /var/lib/ | grep mysql
    drwxrw-r-- 19 mysql root 4.0K Dec 2 22:29 mysql
    $ ls -la /var/ | grep lib
    drwxr-xr-x 29 root root 4.0K Nov 28 19:59 lib
    $ ls -la / | grep var
    drwxr-xr-x 13 root root 4.0K Nov 28 19:58 var
    so anyone tell me what permissions I have gotten wrong & how can I get mysql to work again?
    Last edited by cool (2012-12-02 18:26:18)

    1. You have to start mysqld as root using either sudo or from your root account
    2. The safest way to start mysql is using the unit file (systemd) or service file (rc.d) -- e.g. 'sudo systemctl mysqld start'
    3. My /var/lib/mysql directory has the following permissions 700 and owner/group is mysql/mysql. With those permissions, you're not going to be able to view the contents of the directory unless you are root or that user.
    Scott

  • Detection Method of Date Modified fails due to copied files date modified change

    I've been working through an issue for some time now and I think it's a bug with SCCM 2012 SP1. I've built literally 50 deployments in "Application Management" in SCCM 2012, but I've been chasing my tail on a few of them throwing the
    "succeeded but couldn't detect" error. The few that have given me problems are all copying text files and then detect the modified date to verify that the file is there. All worked when I initially built them in Windows 8 but are now failing
    randomly...even on a machine where they previously worked and I deleted the files to test the deployment again. 
    What I'm doing:
    My java deployment requires policies which we control with the Deployment.config, deployment.properties and java.policy files. A simple script creates the directories and copies the files. I then create a deployment type for this "ConfigFileCopy.cmd"
    and create a detection rule for each file that I am moving over. The detection rule looks for a "date modified" date between the beginning and end of the date for the day I modified the file. This allows me to modify the files to change our
    java policies and then redeploy them with the "new" modified date as the detection rule, which forces the update.
    The problem:
    When I first created my deployment, everything worked pretty well. The files copy out and the script runs successfully. There were some minor tweaks I need to make to my scripts, so I did and then updated the content for the deployment type. I believe this
    is where things go a little wonky. At this point, my deployment starts failing with the "0x87D00324" error.
    Looking through the logs, everything looks good. The reason configuration manager is failing on detecting the modified date for those files, as it turns out, is because the modified dates don't meet the criteria. So that part is properly failing the detection.
    The problem is that the modified dates are correct on the server but not the client. Looking in c:\windows\ccmcache, I can see multiple folders....presumably one for each version of the application that I updated. Looking at any of the newer content folders
    for this app, the modified dates are the date and time the file was copied out to the workstation, which is incorrect as the file hasn't been modified during that process.
    The odd part, is that this doesn't happen EVERY time on EVERY machine. My primary desktop is windows 8.1 and received the files correctly and installed without issue. My test win 8.1 laptop initially received them correctly, but then as I refined the scripts
    it began picking up the wrong modified dates and started failing.
    I found a similar issue to this existed in SCCM 2007 (http://support.microsoft.com/kb/2276865) so I suspect that this is truly just a bug that hasn't been addressed (or maybe is fixed in R2). Unfortunately
    we have business reasons we can't upgrade to R2 at this time so I'm hoping someone has experienced this and has some sort of work around that might get me by for now. If someone can confirm it is fixed in R2, that would help my case to upgrade as well.  
    I can work around the issue by changing my logic to detect any date greater than a specific date. But I shouldn't have to do that and I'm concerned there are scenarios I haven't thought of that will cause unexpected behavior or failures with that.
     

    This outlines the behavior. It's apparently by design. 
    "SCCM has a habit of changing the ‘Date Modified’ timestamp of all files it delivers when it detects an ‘upgrade’ of the source files for that application. It typically does not touch the timestamp
    of the source files if it delivers a brand new install to a client that has never received the software, however if a single file in the source folder is changed for that application, then SCCM tries to use a previous version of the application in the cache
    (C:\windows\ccmcache) and only downloads the new file that has change. This results in all files having their ‘Data Modified’ timestamp changing (except for the brand new file). Therefore determining if that application has delivered
    successfully using ‘Date Modified’ timestamps is not recommended. The key to seeing this process in action is looking at the file properties in the
    C:\windows\ccmcache\<sccm code> folder for that application, particularly before and after a file is updated in the original source SCCM application folder."
    http://blog.kloud.com.au/tag/sccm/

  • How to make Folder Action work on file, subfolder content change?

    Hi!
    I looking for information in how to make a Folder Action, Work Flow or any action from Automator to work on file change and not only on deletion, moving or insertion. What I want to know is if it's possible to trigger some script or app while monitoring a folder and its contents, files and subfolders, changes. Meaning that when I have a file that has its contents updated the action will be triggered like an txt file that I only insert a new line in it, for example.
    Is there any solution that is not third party? Is there an internal Mac OS X solution that would work on Snow Leopard, Lion and Mountain Lion?

    i have same problem. i would like to move automatically saved Word backup copy to another folder, but the folder action doesn't recognize the save as a new file that needs to be acted upon.

  • DFS File Hash Keeps Changing?

    First some background:
    2 DFS Servers running Storage Server 2008 w/ SP2
    Both servers are in a replication group that replicates a folder in the namespace to both servers.
    The servers are in different AD sites connected by a fast WAN connection.
    The replication schedule is set to 24/7
    The problem I am having is that the replication backlog never catches up.  The backlog is currently at 1,900,000+ files but only from SERVER1 -> SERVER2.  Replication from SERVER2 -> SERVER1 is successful with no backlog.  The majority
    of file changes are made on SERVER1.  After troubleshooting this for a week or so trying to find out why the backlog keeps increasing I've found the following:
    The file hashes on SERVER1 are different than the file hashes on SERVER2 when checked with the DFSRDIAG FILEHASH command.  The hashes are different even on files with the same modified date, NTFS permissions, and size.
    If I run a robocopy and copy files from SERVER1 to SERVER2 the hashes are the same.
    Files I've added as recently as 3/31/2014 with no changes made since have different hashes on both servers which is causing DFS to try to replicate them even though it doesn't need to.
    It seems like something is causing the file hashes to change on every single file in the replicated folder on one of the servers.  I've checked the antivirus (TrendMicro) and it is supported on DFS and isn't even configured to run any scheduled scans.
     I'd like to reseed SERVER2 via robocopy so the hashes are all the same again but I'm afraid that same problem will just happen again.
    Does anyone have any idea why the file hashes would be changing even if the file timestamp, permissions, size, etc the same?

    I've pre-staged all 4TB of files with robocopy and checked the hash on 100 or so files on both servers to make sure they are matching.
    After pre-staging I recreated the replication group and replicated folder.  I am currently waiting on initial sync.  The backlog is currently 2,000,000+ files and hasn't gone down much at all in the past 12 hours.
    SERVER1 is set as the primary and SERVER2 is showing that it is waiting to perform initial replication (Event ID 4102.
    How long should the initial sync take if all of the files have been pre-seeded?  I can't really tell if this is working or not.
    I'm also seeing these errors in the debug logs:
    20140422 09:34:59.293 8444 INCO   514 SessionTask::Step csId:{E8271D03-32D5-4A1B-89F5-35169E365CE3} csName:Corporate state:NEW_SESSION
    20140422 09:34:59.293 8444 DOWN   350 LogExtendedErrorInformation Failed RpcErrorStartEnumeration (not found)
    20140422 09:34:59.293 8444 DOWN  3991 [ERROR] DownstreamTransport::EstablishSession Failed on connId:{F499D9F0-3CC7-4BB0-BA6D-821B7B050CAD} csId:{E8271D03-32D5-4A1B-89F5-35169E365CE3} rgName:[removed] Error:
    + [Error:9027(0x2343) DownstreamTransport::EstablishSession downstreamtransport.cpp:3984 8444 C A failure was reported by the remote partner]
    + [Error:9051(0x235b) DownstreamTransport::EstablishSession downstreamtransport.cpp:3984 8444 C The content set is not ready]
    20140422 09:34:59.293 8444 INCO  3566 InConnection::RestartSession Retrying establish contentset session. connId:{F499D9F0-3CC7-4BB0-BA6D-821B7B050CAD} csId:{E8271D03-32D5-4A1B-89F5-35169E365CE3} csName:Corporate
    20140422 09:34:59.293 8444 INCO   774 [WARN] SessionTask::Step (Ignored) Failed, should have already been processed. Error:
    + [Error:9027(0x2343) InConnection::EstablishSession inconnection.cpp:3657 8444 C A failure was reported by the remote partner]
    + [Error:9027(0x2343) DownstreamTransport::EstablishSession downstreamtransport.cpp:4005 8444 C A failure was reported by the remote partner]
    + [Error:9027(0x2343) DownstreamTransport::EstablishSession downstreamtransport.cpp:3984 8444 C A failure was reported by the remote partner]
    + [Error:9051(0x235b) DownstreamTransport::EstablishSession downstreamtransport.cpp:3984 8444 C The content set is not ready]
    20140422 09:34:59.293 8444 TASK   948 TaskPool::Sleep New sleeper thread inserted. Sleepers: 2
    20140422 09:34:59.636 3640 CFAD 10537 Config::AdReader::Peek Subscriptions Checksum, old = 53893317, new = 53893317
    20140422 09:35:00.167 1312 USNC  1319 UsnConsumer::ProcessUsnRecord Filtered USN_RECORD:

  • File Icons have changed

    I just noticed that all of my pdf file icons have changed to the iTunes icon.
    Would anyone have any idea why this may have happened and how to change them back?
    There are no problems with opening or viewing the files - they still open in Preview - but in the Finder they show up as the iTunes icon? Any ideas?
    Thanks,
    AK

    akpud wrote:
    Great suggestion - thanks! It did change the icon globally - but then when I switched it back to Preview - it went back to the 'iTunes' icon.
    Where can I go to change the Preview icon (which is probably want's broken)?
    Preview icon is kept inside Preview application package. control-click on Preview.app and select "show package contents". go to Contents->Resources. the file is called preview.icns. However, there is no way that file got substituted by the itunes icon. Morte likely something is wrong with the Launch services database.
    Try the following. delete the file homedirectory/library/preferences/com.apple.LaunchServices.plist and log out/in. if that doesn't help run the following command in terminal
    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchSe rvices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

  • File extension not changing when Save as

    Hi!
    I have a strange problem. For example; I have a .psd file open and want to save it as a .jpg file. I choose Save as. The dialogue Save as opens and displays the file name. But when I choose jpg as File format the extension behind the File name doesn't change from .psd to .jpg. I have to manually change it. It's the same with other file extensions.
    Is this a bug? I experience the same problem on two different installations.
    I use Creative Suite 4, Photoshop version 11.0.1.
    Fredrik

    No, I have the "Hide Extensions for Known File Types" disabled. The file name is "name.psd". No double extensions.
    I also have tried to change the Photoshop setting "File extensions: uppercase/lowercase" but it's the same.
    I think I got the problem when I upgraded from CS3 to CS4. After that I've also upgraded Photoshop to 11.0.1. It's also strange that I'm having the same problem on two differnet installations.

  • ITunes corrupting video files on metadata changes

    I have some video tutorials that I've been attempting to add to my iTunes library so I can watch them on my iPhone and appleTV.
    The videos copy into my library successfully. They play fine on my mac / phone / aTV as long as I don't change any metadata.
    But as soon as I try and change some metadata...
    Well, things are getting weird.
    Sometimes I've been able to change the metadata on the file without any issue. However, most of the time, I make a change (album art, title, album name) that results in a pinwheel. The program seems to hang for a bit but then makes the change. Everything looks fine and until you try and play the video which will no longer play. Not in iTunes. Not in the finder. Nothing. Even opening the file in iTunes causes the program to crash.
    I'm a little confused, as I've been able to add videos before and make changes to every bit of metadata that my heart desired with no issues.
    I'm even more confused that the problem is intermittent and while this problem happens 90% of the time, it miraculously doesn't when I try to show / explain what's happening.
    It seems to me that there's most likely something wrong on my end within my iTunes library, but I'm not shure where/how to start troubleshooting.
    Anyone with any ideas or advice, your comments and suggestions are valued and appreciated. 
    Thanks,
    Ian
    ps. I'm running the most current build of Lion and iTunes.

    Hi all,
    same problem here, but in a windows (shame on me...) network:
    * Two PCs w/ Win 7 64-bit
    * iTunes 10.7.x
    * iTunes library on a D-LINK DNS-320 (firmware: 2.02.x)
    After editing metadata of video files (adding art, changing title OR adding some details like year) the file is corrupt and will no longer play: not in iTunes, not in Quicktime, neither VLC nor MPC or any other Windows video software.
    This happens always(!), it doesn't matter what PC I use to edit the metadata. Doesn't matter, which video encoder (Freemake, Aisee, even Quicktime and it's ATV-profile) I use. The original video input format doesn't matter.
    Downgrading the D-Link firmware to 1.9 and/or iTunes to 10.6 doesn't give a result.
    Today even some mp3 got corrupted after adding cover art. Therefore i can't believe the file size is the reason.
    Maybe this is a hint: In Windows Explorer (something like the finder on a mac) I can't change the owner nor the user rights of the (corrupted or not yet corrupted) file. Is there any problem known relating to iTunes read-write-ability and NAS user rights whr storing the iTunes library on an external HDD?
    What about the library size or the amount of media objects (130 movies, 500 TV Shows, 15000 mp3, ...)?
    Any ideas or solutions anyone?
    Or a good mp4-tagger (incl. cover option) for Windows?
    regards,
    martin

  • Include files filename pattern change request

         Could you guys be my heros and rename the include files in the TLF source to NOT be *.as?
    FDT hates that and won't let me compile because it detects that the file doesn't contain a valid class.
    eg, in my local copy, I changed them to *.as.inc and everything's lovely.

    Update: there's not much we can do in the short term, but in the longer term we're investigating a solution. I've written a bug for this. I'm afraid in the meantime you'll have to keep renaming the files.
    Thanks!
    - robin

  • Check if a file exists in network dir (JS)

    I've found an old post that has pointed me at:
    if (myFile.exists){
    alert("File Exists");
    else
    alert("File doesn't exist");
    The problem is that when I use the path  macname/volumes/dir/folder/folder/file.indd (which was created from variables) as myFile the script doesn't find a file that I know exists. All I get is the "File doesn't exist" alert.
    Do I need to define myFile as being a string?
    I'm still fumbling my way around JS, and converting Applescripts to JS to work cross-platform. Thanks in advance....

    To get the path to a file i normally use this little script:
    // JavaScript Document
    var myFile = File.openDialog("Choose a File");
    if((myFile != "")&&(myFile != null)){
        alert("Path: " + myFile + "\nType: " + myFile.type);
    Perhaps this c/p can help you:
    function mounter() {
        var myDocument = app.activeDocument;
        // we are saving the preview
        var destination = "/Volumes/myfoldername";
        //var destination = "/Users/tn/Documents/Tryksager/Design/";
        var volume = "afp://sub.dn.com/myfoldername";
        try {
            with (myDocument) {
                if(file_name = get_filename(name)) {
                        if (Folder(destination).exists) {
                        //alert("Folder exists: " + Folder(destination));
                        } else {
                        if (confirm ("Mount volume?", false, "Mount volume")) {
                            mount_volume();
                            // volume mounted, do what you need
                        } else {
                            alert("Could not mount");
        } catch ( err ) {
            // No error warning
        function mount_volume() {
            var myScriptFolderPath = pluginPath + "/resources/"; // Path to the applescript
            app.doScript(File(myScriptFolderPath + "mountvolume.scpt"),ScriptLanguage.applescriptLanguage);
    //The applescript for mounting volumes
    (*set user_name to ""
    set Dialog_1 to display dialog "Please enter your user name" default answer ""
    set the user_name to the text returned of Dialog_1
    set pass_word to ""
    set Dialog_2 to display dialog "Please enter your password" default answer "" with hidden answer
    set pass_word to the text returned of Dialog_2*)
    tell application "Finder"
        try
            mount volume "afp://mysub.mydn.com/myfolder" as user name "myusername" with password "mypassword"
        end try
    end tell
    Thomas B. Nielsen
    http://www.nobrainer.dk

  • Deleting files doesn't free up space on external drive

    Hi all,
    I've actually found the answer to my initial query, I would imagine its a common issue. But I have a couple of questions.
    When you delete files from an external HD the amount of space available doesn't change and according to what I have found, you need to empty your trash in order for free space to be recognised.
    Basically I'd like to know...
    1. Why this is the case. I like the fact that external files are added to the local trash in case you mistakenly deleted anything but considering it's been moved to another file system why would it not free up space?
    2. Is there a way to delete certain files from the trash? In a case where I wanted to free up space on an external drive but didn't want to empty my trash.
    Many thanks
    Mikee

    Expaning a bit on #1 -
    Every volume (volume = a drive/disk or a partition on a partitoned drive) has its own Trash, which is actually an invisible, specialized folder.
    For user interface convenience, the Trash folders for all mounted volumes are displayed as a common item, the visible Trash.
    One way to see this is to place something on a removoable, writeable volume such as an external drive into the Trash. When you open the Trash you will see the item in there. Then dismount the external drive, and look in the Trash again - the item will be gone. Remount the external drive, and look in the Trash again - the item will be back.
    If you have things in the Trash from different volumes, you can also do a Get Info on one from each volume; the pathname for the item (shown in the Where info line in Get Info) will reveal that the items are actually on separate volumes.

  • Force mask file creation in one dir

    I need to force mask file creation in one dir.
    Basically this is the situation
    "document" is a shared dir, SGID is already set on the dir so all new files are created as group "office".
    But they are created with 644 mask so they are not accessible by other users in the group.
    I do not want change the default user mask with umask because of security reason, but I need that in this dir file are created with 664 mask.
    Suggestion??

    I Think I should run the cronjob each minute in order to prevent problems.
    Is it possible that there is no other way?
    even samba can force mask user and group on per share ......
    There should be another way......

  • Hi when i open my application folder, all the application is shown in trash folder. when i click the application it says this app is in trash first move it out. and when i try to open through finder go it says this file doesn't exist. can some1 plz help?

    hi when i open my application folder, all the application is shown in trash folder. when i click the application it says this app is in trash first move it out. and when i try to open through finder> go it says this file doesn't exist. can some1 plz help? how can i put all my application through application folder?

    Something really odd is going on. In your first screen shot, I noticed that the Applications folder does not have the proper icon displayed in the side bar. Also, in the title bar it lists it as Applications 08-59-29-909.
    Not sure where it's picking up that odd name, unless it's because it's still truly within the Trash folder.
    Try this. In the Finder > Preferences > General > turn on "Always open folders in a new window". (I have a feeling you have the default setting with this off).
    Now, in Finder > Go > move down and open the Applications Folder from there. Now open the folder where you see all your applications that you show in your screen shot, select all, and move them to this true appliactions folder.
    This is what you should properly seeing (but with different apps listed):
    See how the Applications folder has the icon of the letter A shaped with a pencil, ruler & pen.

Maybe you are looking for

  • Implicit and explicit Type conversion using Type object in heap

    Hi, I am surprised how Implicit and explicit Type conversion works using Type object in heap. for example when implicit type conversion occur what pointer it returns to object and similarly with explicit type conversion.

  • How to find out when 'enable secret' and username secret' was set/changed

    Hi, I was wondering if it is possible to find out when 'enable secret' and username secret' was set or changed last time on an IOS based machine. Is there any show command or kind of timestamp or MIB which can be read out? tnx Ralf

  • NOKIA E72 water damage?!

    Hi, Some drops of rain water fell on my Nokia E72 today. As soon as I got back home..I wiped my phone clean..opened the back panel and wiped the battery and I blew-dry d entire fone too . All functions seem to be ok except the headset jack which is p

  • Linksys WRT-1900AC and Dynamic Frequency Selection(DFS)

    Hello All Does anybody know if the Linksys Router WRT-1900AC will support Dynamic Frequency Selection(DFS) by a newer Firmwareupdate? I don't understand why this feature has not been added yet Second why does i have to set the 5GHZ WLAN to mixed to u

  • Load moniternig issue Program DBIF_DSQL2_SQL_ERROR

    Hi Gurus i have on process chain program failed.  It geeting error ABAP/4 processor: DBIF_DSQL2_SQL_ERROR. How can i reduce this problem please help me out Thanks in advance Praveenkumar yagnamurthy