EzDevInfo.com

rename interview questions

Top rename frequently asked interview questions

Rename a file using Java

Can we rename a file say test.txt to test1.txt ?

If test1.txt exists will it rename ?

How do I rename it to the already existing test1.txt file so the new contents of test.txt are added to it for later use?


Source: (StackOverflow)

In a Git repository, how to properly rename a directory?

In a Git repository, how to properly rename a directory? I think it should work to copy the directory to be renamed to a new directory with desired name, and delete the old directory, and git add, git commit and push everything. But is this the best way?


Source: (StackOverflow)

Advertisements

Renaming a branch in github

I just renamed my local branch using

git branch -m oldname newname

but this only renames the local version of the branch. How can I rename the one in github?


Source: (StackOverflow)

Renaming xcode 4 project and the actual folder

I know how to rename the project in Xcode 4, but how do you rename the source folder? The thing is that renaming the project in Xcode, does only rename within Xcode (Though it is progress compared to previous) - but why Xcode is not renaming the folder in the filesystem I don't know.


Source: (StackOverflow)

JavaScript: Object Rename Key

Is there a clever (i.e. optimized) way to rename a key in a javascript object?

A non-optimized way would be:

o[ new_key ] = o[ old_key ];
delete o[ old_key ];

Thanks in advance for your help.


Source: (StackOverflow)

How do you rename a Git tag?

Today I was looking through the logs for a project and realized that I fat fingered a tag name some time ago. Is there some way to rename the tag? Google hasn't turned up anything useful.

I realize I could check out the tagged version and make a new tag, I even tried that. But that seems to create a tag object that isn't quite right. For one,

git tag -l

lists it out of order relative to all of the other tags. I have no idea if that's significant, but it leads me to believe that the new tag object isn't quite what I want. I can live with that, because I really only care that the tag name matches the documentation, but I'd rather do it "right", assuming there is a right way to do this.


Source: (StackOverflow)

Renaming columns in pandas

I have a data table using pandas and column labels that I need to edit to replace the original column labels.

I'd like to change the column names in a data table A where the original column names are:

['$a', '$b', '$c', '$d', '$e'] 

to

['a', 'b', 'c', 'd', 'e'].

I have the edited column names stored it in a list, but I don't know how to replace the column names.


Source: (StackOverflow)

How do I quickly rename a MySQL database (change schema name)?

The MySQL manual at MySQL covers this.

Usually I just dump the database and reimport it with a new name. This is not an option for very big databases. Apparently RENAME {DATABASE | SCHEMA} db_name TO new_db_name; does bad things, exist only in a handful of versions, and is a bad idea overall.

This needs to work with InnoDB, which stores things very differently than MyISAM.


Source: (StackOverflow)

git: renaming branches remotely? [duplicate]

This question already has an answer here:

If there is a repository that I only have git:// access to (and would usually just push+pull), is there a way to rename branches in that repository in the same way that I would do locally with git branch -m?


Source: (StackOverflow)

Easiest way to rename a model using Django/South?

I've been hunting for an answer to this on South's site, Google, and SO, but couldn't find a simple way to do this.

I want to rename a Django model using South. Say you have the following:

class Foo(models.Model):
    name = models.CharField()

class FooTwo(models.Model):
    name = models.CharField()
    foo = models.ForeignKey(Foo)

and you want to convert Foo to Bar, namely

class Bar(models.Model):
    name = models.CharField()

class FooTwo(models.Model):
    name = models.CharField()
    foo = models.ForeignKey(Bar)

To keep it simple, I'm just trying to change the name from Foo to Bar, but ignore the foo member in FooTwo for now.

What's the easiest way to do this using South?

  1. I could probably do a data migration, but that seems pretty involved.
  2. Write a custom migration, e.g. db.rename_table('city_citystate', 'geo_citystate'), but I'm not sure how to fix the foreign key in this case.
  3. An easier way that you know?

Source: (StackOverflow)

How to rename all folders and files to lowercase on Linux?

I have to rename a complete folder tree recursively so that no uppercase letter appears anywhere (it's C++ sourcecode, but that shouldn't matter). Bonus points for ignoring CVS and SVN control files/folders. Preferred way would be a shell script, since shell should be available at any Linux box.

There were some valid arguments about details of the file renaming.

  1. I think files with same lowercase names should be overwritten, it's the user's problem. When checked out on a case-ignoring file system would overwrite the first one with the latter, too.

  2. I would consider A-Z characters and transform them to a-z, everything else is just calling for problems (at least with source code).

  3. The script would be needed to run a build on a Linux system, so I think changes to CVS or SVN control files should be omitted. After all, it's just a scratch checkout. Maybe an "export" is more appropriate.


Source: (StackOverflow)

Rename MySQL database [duplicate]

This question already has an answer here:

I created a database with the name of hrms. Now I need to change database name to sunhrm. But, It is disabled in MySQL workbench. Can I do that on the Linux server itself?


Source: (StackOverflow)

Undo git mv (rename)

What is the right way to undo a rename in git, like:

git mv file1 file2

Source: (StackOverflow)

eclipse workspace: how to rename workspace

There is no option in the file menu to rename a workspace. Is the recommended practice to close eclipse, rename the folder, and re-open? I worry about some potential dangling references in configuration files corrupting my workspace/projects...

Thanks!


Source: (StackOverflow)

Batch Renaming of Files in a Directory

Is there an easy way to rename a group of files already contained in a directory, using Python?

Example: I have a directory full of *.doc files and I want to rename them in a consistent way.

X.doc -> "new(X).doc"

Y.doc -> "new(Y).doc"


Source: (StackOverflow)