Rename files & folders recursively in Windows (7) to [A-Za-z0-9-] - windows

I search a solution to rename files and folders recursively in Windows (7) to [A-Za-z0-9-].
I will post a question, but this is not perfect and without folder rename. I search also for a better solution. A batch file is welcome.

This solution is not realy perfect. Also search for a better solution.
I have do it with FreeCommander XE:
This tutorial works only recursively for files. With folder, this have a problem with recursively, because subfolder with already renamed parent folder are not renamed.
Hint: Please be absolutely carefull. You can rename all filenames irreversible!
When you have the capacity, make it with a copy. That is not a joke.
Open the Folder in a tab.
Check, that the tab with the folder is active (bold path name).
Click the "Search" icon.
It opens a new window.
File name: *
Click "Find".
Mark all Files.
Menue: File → Export to file container → Export selected items
It opens all the files in a temporary folder in a new tab in the main window.
In this (C:TmpFileContainer-1.fcc) please mark only all files.
Menue: File → Multirename
It opens a new window.
Special (two bit) chars INFO:
search = aequivalent → alternative
[i don't know] = Ä → Ae
+ñ = ä → ae
+û = Ö → Oe
+Â = ö → oe
+£ = Ü → Ue
++ = ü → ue
[i don't know] = ẞ → SS
+ƒ = ß → ss
[i don't know] = you know it? please write it in a comment. [Question: What is the name of this References?]
In the Multirename window:
First: search & replace the special (two bit) chars, because, this have not special chars included (see below at regular expression).
Select "Replace all occurence".
Select "Exlcude extension".
And Select "Auto Preview" and check the result befor click the "Rename" button.
After the rename click "Reload".
Please be absolutely carefull!
search → replace
+ñ → ae
+û → Oe
+Â → oe
+£ → Ue
++ → ue
+ƒ → ss
Make a new search:
search for: +
(you find eventually an another special char / two bit char)
Do the same with these as with the others.
Search an replace for HTML URL Encoding Reference:
List of entities and characters: https://www.w3schools.com/tags/ref_urlencode.asp
In most cases not all references are present in the filenames.
Yet search & replace with Regular expression.
Please be absolutely carefull!
Select "Replace all occurence".
Select "Exlcude extension".
Select "Regular expression".
search → replace:
\W → -
Info: The capital W match all chars, except a-zA-Z0-9. But a-zA-Z0-9 included unfortunately ñ û Â and similar and except it. Therefore first rename the special (two bit) chars.
Or use an another pattern like this:
_|&|\.|\s|\+|\(|\)|=
Further replaces (Umlaute):
Select "case sensitive".
Select "Replace all occurence".
search → replace
Ä → Ae
Ö → Oe
Ü → Ue
ä → ae
ö → oe
ü → ue
ß → ss
Last but not least:
search → replace:
Select "Replace all occurence".
_ → -
Special search → replace:
Leading dashes:
^- →
(rename to nothing)
Trailing dashes:
-$ →
(rename to nothing)
Don't forget to check the renamed filenames every time befor click the "Rename" button.

Related

Character replacement batch file

I'm trying to do a batch script using Windows command line to convert some characters for example:
É to Й
Ö to Ц
Ó to У
Ê to К
Å to Е
Í to Н
à to Г
Ø to Ш
Ù to Щ
Ç to З
with no success. That's because I am using a program that does not support a Cyrillic font.
And I have already the file with these words, like:
ОБОГРЕВ ЗОНЫ 1
ДАВЛЕНИЕ ЦВЕТА 1
...
and so on...
Is it possible?
I'm guessing that you'd like to convert the character set (alias code page) of a file so you can open and read it.
I'm assuming you are using a Windows computer.
Let's say that your file is russian.txt and when you open it with notepad, the characters doesn't make any sense. The russian.txt file's character encoding is most propably ANSI and it's code page is Windows-1251.
Some words about character encoding:
In ANSI one character is one byte long.
Different languages have different code pages: Windows-1251 = Russian, Windows-1252 = Western Languages (English, German, Swedish...), Windows-1253 = Greek ...
In UTF-8 English characters are one byte long and non-English characters two bytes long.
In Unicode all characters are two bytes long.
UTF-8 and Unicode doesn't need code pages.
You can check the encoding by opening the file in notepad and clicking File, Save As. At the right bottom corner beside the Save-button you can see the encoding.
With some googling I found a site where you can do the character encoding conversion online. I Haven't tested it, but here's the address:
http://i-tools.org/charset
I've made a script (= a small program) which changes the character encoding from any ANSI and code page combination to UTF-8 or Unicode or vice versa.
Let's say you have and English Windows computer and want to convert the russian.txt (ANSI / Windows-1251) to UTF-8.
Here's how:
Open this web-page and copy the script in it to the clipboard:
VB6/VBScript change file encoding to ansi
Create a new file named ConvertCharset.vbs to the same folder, where the russian.txt is, say C:\Temp.
Open the ConvertCharset.vbs in notepad (right click+edit) and paste.
Open CMD (Windows-button+R, cmd, Enter).
In CMD-window type (hit Enter-key at each end of the line):
cd C:\Temp\
cscript ConvertCharset.vbs /InputCharset:Windows-1251 /OutputCharset:utf-8 /InputFile:russian.txt /OutputFile:russian_utf-8.txt
Now the you can open the russian_utf-8.txt in notepad and you'll see the Russian characters OK.
More info:
http://en.wikipedia.org/wiki/Character_encoding
http://en.wikipedia.org/wiki/Windows-1251
http://en.wikipedia.org/wiki/UTF-8
VB6/VBScript change file encoding to ansi

Bash keybinding with "bind" - avoid recursion like noremap in Vim

I've remapped the following keys in Bash:
bind '"a" "b"'
bind '"b" "c"'
If I press a or b both times a c will be printed.
How can I map the keys so that by pressing a and b will be printed and only by pressing a and c will be printed (like with Vims **nore**-map)?
You can make a char in the right part a literal with a preceeding "^V":
bind '"x":"^Vx "'
The key sequence to enter the text after colon is:
" Ctrl-v Ctrl-v x space "
In bash "Ctrl-v x" results in a literal x, without key-mapping interpretation .
You may find it useful to build your own keymapping file which maps the numeric signal you get from the keyboard to a character. This is done with the loadkeys command i.e. if you're switching to the dvorak layout you can do (this is a verbose way to show you the location of the map files:
loadkeys /usr/share/keymaps/i386/dvorak/dvorak.map.gz
You could copy the map file for the layout you use and change the relavent chars, and load your modified mapping. I think loadkeys only affects the command line, though there are similar methods for changing the behaviour in X I believe.

Sublime Text 2: Trim trailing white space on demand

I know that Sublime Text 2 can delete the trailing white space on files upon saving.
When working in a team and commiting a change to a file this tends to produce huge diffs which make peer code review more cumbersome. For that reason I prefer to only do the white space cleaning when I'm commiting huge changes to a file anyway and leave whitespace as it is for the minor changes.
I would like to know if there's any command for executing the trimming of the white space on demand on a file, other than "Activate trimming on save > Save file > Deactivate trimming".
Searching in the Documentation and on stackoverflow didn't show anything relevant, all the links seem to talk about the auto trimming on save.
I use these steps for a quick on-demand solution within Sublime Text:
Find > Replace...
Find What: [ \t]+\n
Replace With: \n
Replace All
You could also do this for a large set of files via
Find > Find in Files...
Find: [ \t]+\n
Where:
Replace: \n
Replace
Beware: using this plugin makes Sublime Text significantly slower
I use TrailingSpaces plugin for this.
Highlight trailing spaces and delete them in a flash.
ST2 provides a way to automatically delete trailing spaces upon file
save. Depending on your settings, it may be more handy to just
highlight them and/or delete them by hand. This plugin provides just
that!
Usage: click "Edit / Trailing Spaces / Delete".
To add a key binding, open "Preferences / Key Bindings - User" and add:
{ "keys": ["ctrl+alt+t"], "command": "delete_trailing_spaces" }
You can simply use a regex to remove trailing whitespaces:
Find > Replace...
Find what: [^\S\r\n]+$
Replace with: leave empty.
Click 'Replace All'
[^\S\r\n]+$ is Regex for "at least one whitespace character (so spaces and tabs but not newlines, using a double negation) followed by the end of the line"
Regular Expression must be enabled:
This method isn't perfect, but uses no plugins or settings and works in most situations.
Multi-Select and move cursor to the end of every line
Hold CTRL-Shift, Press Left, Right
The spaces and tabs at the end of the lines should now be selected. Press Delete or Backspace
Note - Special characters such as ( and + may also be selected at the end of the line at this point, not just spaces.
How to Multi-Select all lines:
One way is to use the middle mouse key to select vertically then hit the End Key if it's a small selection.
With hot-keys:
CTRL-A (select all)
CTRL-SHIFT-L (place cursor on all lines selected)
END (Go to end of lines)
You can also use the find function to find something that will be in every line, like the space character:
\s (using regex)
Click Find All
Press the "End" key to get multiple cursors at the end of each line
Sample Text:
text and number 44 more text and a space
text and number 44 more text and 2 tabs
text and number 44 more text and no space or tab
text and number 44 more text after a line feed
I found a soulution here:
http://www.sublimetext.com/forum/viewtopic.php?f=4&t=4958
You can modify the package
trim_trailing_white_space.py
located in the default packages directory, this way:
import sublime, sublime_plugin
def trim_trailing_white_space(view):
trailing_white_space = view.find_all("[\t ]+$")
trailing_white_space.reverse()
edit = view.begin_edit()
for r in trailing_white_space:
view.erase(edit, r)
view.end_edit(edit)
class TrimTrailingWhiteSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit):
trim_trailing_white_space(self.view)
class TrimTrailingWhiteSpace(sublime_plugin.EventListener):
def on_pre_save(self, view):
if view.settings().get("trim_trailing_white_space_on_save") == True:
trim_trailing_white_space(view)
class EnsureNewlineAtEof(sublime_plugin.EventListener):
def on_pre_save(self, view):
if view.settings().get("ensure_newline_at_eof_on_save") == True:
if view.size() > 0 and view.substr(view.size() - 1) != '\n':
edit = view.begin_edit()
view.insert(edit, view.size(), "\n")
view.end_edit(edit)
Now you can add the command to your keymap configuration:
{ "keys": ["your_shortcut"], "command": "trim_trailing_white_space" }

Trouble writing é in emacs

I'm using emacs(version below) on Windows7(x64). I have trouble writing a é in emacs.
I would like to hit '´' and 'e' to get the char 'è'.
I have used emacs for >20years and I do not remember it has been a trouble before. It has worked before, I'm almost sure of... There is no problem displaying the 'é', and I can cut-and-paste from other programs/buffers. The problem is to type it.
Any solution would be much appreciated.
BR/Tomas
(GNU Emacs 23.4.1 (i386-mingw-nt6.1.7601) of 2012-02-04 on MARVIN)
Try C-x8'e.
Typing C-x8C-h will display an input table for all Latin-1 characters.
Add this to your .emacs file if you want to type "'" "e" to get "é"
(defadvice switch-to-buffer (after activate-input-method activate)
(activate-input-method "latin-9-prefix"))
If you want to just activate it for one session, do
M-x set-input-method
and enter
latin-9-prefix
If you're using a keyboard setting with dead keys, which makes ' + e = é, like the us-international keyboard map (if I remember correctly?) you might want to put (require 'iso-transl) somewhere in your emacs init file.
I don't use Windows, but I don't see any warning about it in the iso-transl elisp file.
Here is a list of the most common special characters to use and also type fluently.
ä - M-d
Ä - M-D
ë - M-k
Ë - M-K
ï - M-o
Ï - M-O
ö - M-v
Ö - M-V
ü - M-| (argh, I've to use shift for the non-capitals and vice versa)
Ü - M-\ (dito.)
ß - M-_ (dito.)
é - M-i
É - M-I
è - M-h
È - M-H
à = M-`
À = M-#
Courtesy - LINK

TextMate find text and then delete entire line?

I'll show you what I want to do using a textmate command or bundle:
Lets say we have the following document:
foo
diddy
bah
foo
foobah
diddy
I want to find and delete all the lines matching bah, the desired ouput in this case would be:
foo
diddy
foo
diddy
Thanks!
With the document you want to filter open,
Cmd-F to bring up the Finder
window
Next, below the two text-entry boxes,
click Regular Expression
In the Find text box, type in
this regexp (without the spaces):
^ . * ? bah . * ? $
In the Replace text box, do not type
in anything--make sure it blank,
i.e., no whitespace characters
With the cursor at the beginning of
the document you want to filter,
click one of the buttons at the
bottom of the Find Window--e.g.,
Replace All to remove all of the matching lines in one step, or
Replace and Find to step through the lines one at a time
That's it.
Here's a more automated way to do the same thing:
from the Menu Bar, select Filter
Through Command from the Text
pull-down menu
enter this into the text box at the
top of the small window that appears:
sed ' / ^ . * bah . * $ / d '
select Document as Input and select
Replace Document as Output
Click Execute
[Note: i inserted spaces between the regexp tokens in both examples because for some reason the asterisks '' were not rendering in HTML page]
Building on top of #doug's answer
Since the user wants to delete the line after the match, the solution using Regex is
^ . * ? bah . * ? $\n
Matching the \n at the end will remove the line

Resources