Sponsored Content
Top Forums UNIX for Dummies Questions & Answers chm and pdf help in terminal (rename) Post 302196195 by era on Saturday 17th of May 2008 05:10:10 AM
Old 05-17-2008
You just need to escape or double quote the special characters on the command line. In my experience, Bash does this for you automatically with tab completion, although there are some minor glitches.

The only characters you absolutely cannot use in a file name are slash (because it's used to separate directories) and ASCII null (because it's used internally to terminate strings).

Here's a quick attempt at batch rename.

Code:
for f in *; do
  case $f in *[!A-Za-z0-9_-]*)  mv -i "$f" "`echo "$f" | tr " " _ | tr -dc A-Za-z0-9_-`";; esac
done

This might be even a little bit too conservative in what characters it will accept in a file name, but at least it's a start.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to read *.chm file under linux?

How can I read *chm (compiled HTML) file under linux? (2 Replies)
Discussion started by: HOUSCOUS
2 Replies

2. UNIX for Dummies Questions & Answers

Reading *.chm files?

I have a bunch of e-books I got but i can't open them. Can I somewhat convert them into html? I don't have an X-server yet so any GUI-programs are out of the question. Are there any programs I might have? Running Debian. Regards Richard (3 Replies)
Discussion started by: riwa
3 Replies

3. UNIX for Dummies Questions & Answers

How to rename Xterm terminal in VNC session

Hi All, We are using VNC viewer to login to remote server. Remote server is running with Red Hat linux 3.0. Our problem is, we are unable to rename xterm terminal so is there any way we can rename? Thanks a lot in advance for your valuable inputs. Regards, Bachegowda (0 Replies)
Discussion started by: bache_gowda
0 Replies

4. UNIX for Advanced & Expert Users

how to view .chm format files?

how can i open the .chm format files in fedora7 and rhel3,4 files? (2 Replies)
Discussion started by: praveen_b744
2 Replies

5. UNIX and Linux Applications

Application to create/edit chm files

Does someone knows an application to create/edit *.chm files? Any suggestion will be much appreciated! (2 Replies)
Discussion started by: agasamapetilon
2 Replies

6. Shell Programming and Scripting

How to open a pdf file from terminal?

how to open a .pdf file from terminal not using gpdf I work on fedora 12 and default application assigned for viewing the pdf files is document-viewer (3 Replies)
Discussion started by: rrd1986
3 Replies

7. Shell Programming and Scripting

Find and Rename File using Terminal

I need help finding a file through terminal and then renaming it automatically. Here is what I have so far to find the file: cd /User/Applications find . */SourceM.app/banner.png | while read line; do mv "$line" banner-.png; done I want the script to rename the file "banner.png" to... (6 Replies)
Discussion started by: rbisconti97
6 Replies

8. UNIX for Dummies Questions & Answers

Split and Rename files using Terminal and bin/bash

I have a file named Me_thread_spell.txt that I want to split into smaller files. I want it to be split in each place there is a ;;;. For example, blah blah blah ;;; blah bhlah hlabl awasnceuir asenduhfoijhacseiodnbfxasd;;; oabwcuhaweoir;;; This full file would be three separate files... (7 Replies)
Discussion started by: mschpers
7 Replies
vis(1)							      General Commands Manual							    vis(1)

NAME
vis, inv - make unprintable and non-ASCII characters in a file visible or invisible SYNOPSIS
file ... file ... DESCRIPTION
reads characters from each file in sequence and writes them to the standard output, converting those that are not printable or not ASCII into a visible form. inv performs the inverse function, reading printable characters from each file, returning them to non-printable or non-ASCII form, if appropriate, then writing them to standard output; Non-printable ASCII characters are represented using C-like escape conventions: backslash backspace escape form-feed new-line carriage return space horizontal tab vertical tab the character whose ASCII code is the 3-digit octal number n. the character whose ASCII code is the 2-digit hexadecimal number n. Non-ASCII single- or multi-byte characters are examined one byte at a time. For each byte, if it can be displayed as an ASCII character, it is treated as if it is an ASCII character; Otherwise, it is represented in the following conventions: the 8-bit character whose code value is the 3-digit octal number n. the 8-bit character whose code value is the 2-digit hexadecimal number n. Space, horizontal-tab, and new-line characters can be treated as printable (and therefore passed unaltered to the output) or non-printable depending on the options selected. Backslash, although printable, is expanded by vis, to a pair of backslashes so that when they are passed back through inv, they convert back to a single backslash. If no input file is given, or if the argument is encountered, and inv read from the standard input. Options and recognize the following options: Treat new-line, space, and horizontal tab as non-printable characters. expands them visibly as and rather than passing them directly to the output. discards these characters, expecting only the printable expansions. New-line characters are inserted by every 16 bytes so that the output will be in a form that is usable by most editors. Make and silent about non-existent files, identical input and output, and write errors. Normally, no input file can be the same as the output file unless it is a special file. Treat horizontal-tab and space characters as non-printable in the same manner that treats them. Cause output to be unbuffered (byte-by-byte); normally, output is buffered. Cause output to be in hexadecimal form rather than the default octal form. Either form is accepted to as input. EXTERNAL INFLUENCES
Environment Variables determines the language in which messages are displayed. International Code Set Support Single- and multi-byte character code sets are supported. WARNINGS
Redirecting output to an input file destroys the original data. Therefore, command forms such as should be avoided unless the source file can be safely discarded. AUTHOR
was developed by HP. SEE ALSO
cat(1), echo(1), od(1). vis(1)
All times are GMT -4. The time now is 02:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy