Handling renames: svn vs. git vs. mercurial

Git doesn’t track renames at all, but uses heuristic to re-discover them during merge etc. Mercurial tracks renames (the origin version and origin file is recorded) and uses that information during merges. So you have to explicitly tell hg about renames with hg mv, or use hg addremove –similarity for auto-discovery. There has been some … Read more

Re-order columns of table in Oracle

Since the release of Oracle 12c it is now easier to rearrange columns logically. Oracle 12c added support for making columns invisible and that feature can be used to rearrange columns logically. Quote from the documentation on invisible columns: When you make an invisible column visible, the column is included in the table’s column order … Read more

Linux: remove file extensions for multiple files

rename is slightly dangerous, since according to its manual page: rename will rename the specified files by replacing the first occurrence of… It will happily do the wrong thing with filenames like c.txt.parser.y. Here’s a solution using find and bash: find -type f -name ‘*.txt’ | while read f; do mv “$f” “${f%.txt}”; done Keep … Read more

How to zero pad numbers in file names in Bash?

It’s not pure bash, but much easier with the Perl version of rename: rename ‘s/\d+/sprintf(“%05d”,$&)/e’ foo* Where ‘s/\d+/sprintf(“%05d”,$&)/e’ is the Perl replace regular expression. \d+ will match the first set of numbers (at least one number) sprintf(“%05d”,$&) will pass the matched numbers to Perl’s sprintf, and %05d will pad to five digits

Renaming a branch in GitHub

As mentioned, delete the old one on GitHub and re-push, though the commands used are a bit more verbose than necessary: git push origin :name_of_the_old_branch_on_github git push origin new_name_of_the_branch_that_is_local Dissecting the commands a bit, the git push command is essentially: git push <remote> <local_branch>:<remote_branch> So doing a push with no local_branch specified essentially means “take … Read more

Renaming Files with Excel VBA

I think you could do something like this, using the Name function to rename the files, however, you will probably need to make sure the 2 columns have the complete file path, i.e. “C:\Temp\ABC.jpg” Dim Source As Range Dim OldFile As String Dim NewFile As String Set Source = Cells(1, 1).CurrentRegion For Row = 1 … Read more

How to rename file by replacing substring using batch in Windows [closed]

@echo off Set “Filename=how-to-rename-file.jpg” Set “Pattern=rename” Set “Replace=reuse” REM Call Rename “%Filename%” “%%Filename:%Pattern%=%Replace%%%” Call Echo %%Filename:%Pattern%=%Replace%%% :: Result: how-to-reuse-file.jpg Pause&Exit I give you other example for a loop of files: UPDATE: I’ve missed some things in the syntax ’cause fast-typing my last edit, here is the corrected code: @echo off Setlocal enabledelayedexpansion Set “Pattern=rename” Set … Read more

Rename more than one column using withColumnRenamed

It is not possible to use a single withColumnRenamed call. You can use DataFrame.toDF method* data.toDF(‘x3’, ‘x4’) or new_names = [‘x3’, ‘x4’] data.toDF(*new_names) It is also possible to rename with simple select: from pyspark.sql.functions import col mapping = dict(zip([‘x1’, ‘x2’], [‘x3’, ‘x4’])) data.select([col(c).alias(mapping.get(c, c)) for c in data.columns]) Similarly in Scala you can: Rename all … Read more

How to rename rails controller and model in a project

Here is what I would do: Create a migration to change the table name (database level). I assume your old table is called corps. The migration content will be: class RenameCorpsToStores < ActiveRecord::Migration def change rename_table :corps, :stores end end Change your model file name, your model class definition and the model associations: File rename: … Read more

tech