rename
How to rename a component in Angular CLI?
No! There is no command which will change the name of all files generated using the component create command. So created ts, html, css/scss, .spec.ts files need to be manually renamed/edited. I am a frequent user of angular cli and I think this would be a nice-to-have command as some time we just create angular … Read more
Rename file on FTP with PowerShell
Try this: $ftp = [System.Net.FtpWebRequest]::Create(“ftp://username:[email protected]/camera/temp.jpg”) $ftp.KeepAlive = $true $ftp.UsePassive = $true $ftp.Method = “Rename” $ftp.RenameTo = “camera/temp1.jpg” $ftp.UseBinary = $true $response = [System.Net.FtpWebResponse] $ftp.GetResponse()
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
Python: Rename duplicates in list with progressive numbers without sorting list
My solution with map and lambda: print map(lambda x: x[1] + str(mylist[:x[0]].count(x[1]) + 1) if mylist.count(x[1]) > 1 else x[1], enumerate(mylist)) More traditional form newlist = [] for i, v in enumerate(mylist): totalcount = mylist.count(v) count = mylist[:i].count(v) newlist.append(v + str(count + 1) if totalcount > 1 else v) And last one [v + str(mylist[:i].count(v) … Read more
How do you change the capitalization of filenames in Git?
Starting Git 2.0.1 (June 25th, 2014), a git mv will just work on a case-insensitive OS. See commit baa37bf by David Turner (dturner-tw). mv: allow renaming to fix case on case-insensitive filesystems “git mv hello.txt Hello.txt” on a case-insensitive filesystem always triggers “destination already exists” error, because these two names refer to the same path … Read more
How do I rename a MySQL database (change schema name)?
For InnoDB, the following seems to work: create the new empty database, then rename each table in turn into the new database: RENAME TABLE old_db.table TO new_db.table; You will need to adjust the permissions after that. For scripting in a shell, you can use either of the following: mysql -u username -ppassword old_db -sNe ‘show … Read more