I have to rename multiple files in directory by removing first 5 characters for each filename.
How can I do this i bash/shell? I'm using Ubuntu 11.10. Thanks.
We're in the process of replacing our SQL Server and have decided that renaming the server itself is going to be much easier than changing everything else to point to a new name. We found instructions on changing the SQL Server instance name to match the computer name which look like this:
sp_dropserver 'OLDSERVER'
sp_addserver 'NEWSERVER', local
Though SQL Enterprise Manager doesn't seem to like those together. I had to change it to the following to make it work together:
sp_dropserver 'OLDSERVER'; GO
sp_addserver 'NEWSERVER', 'local'; GO
Which is not bad, but I would prefer things to be more automated. Since @@ServerName returns the name of the instance, I figured out how to automate the first line:
sp_dropserver @@ServerName; GO
I also learned that SERVERPROPERTY('ServerName') is supposed to return the computer name, so I thought I could maybe use that to automate the second part, but this didn't work:
sp_addserver SERVERPROPERTY('ServerName'), 'local'; GO
I tried setting a variable, which I need to do anyway to update the SQL Agent jobs, but that didn't work either:
DECLARE @srv sysname;
SET @srv = CAST(SERVERPROPERTY('ServerName') AS sysname);
sp_addserver @srv, 'local'; GO
Incorrect syntax near 'sp_addserver'.
I would very much like to not have to hardcode the new server name into the script, to make this more easily reusable. Anybody got any ideas?
Replace ACDC to AC-DC
For example we have these files
ACDC - Rock N' Roll Ain't Noise Pollution.xxx
ACDC - Rocker.xxx
ACDC - Shoot To Thrill.xxx
I want them to become:
AC-DC - Rock N' Roll Ain't Noise Pollution.xxx
AC-DC - Rocker.xxx
AC-DC - Shoot To Thrill.xxx
I know that sed or awk is used for this operation. I can't google anything so I'm asking for your help =) Could you please provide full working shell command for this task?
Feedback: Solution for OSX users