General :: Shell - Rename A File From Something Without Spaces To Something Containing Spaces?

Jan 26, 2010

Is it possible, in Linux, to rename a file from something without spaces to something containing spaces? I know I can create directories and files with spaces by doing:

mkdir "new dir" and:

touch "new file.txt"

I want to rename files from:

imgp0882.jpg to something like:

20091231 1243 some topic.jpg

And how would it look in a shell script that uses parameters like:

for i in *.jpg do
rename "$i" "$somepath/$mydate $mytime $mytopic$extension"
?

I'm new to Linux (using PCLinuxOS 2009.2), coming from Windows, and I've written myself a little shell script to download files from my camera and then automatically rename them according to a date-and-topic pattern. As you can guess by now, I'm stuck on the bit about renaming. If you want to see my script, here's a copy. I'm not using jhead for this renaming because that only works with JPEG files but I want a single solution for any media format including videos.

View 2 Replies


ADVERTISEMENT

General :: Bash - Rename Files With Spaces Using System Shell?

Jun 8, 2011

I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't recognize the file or directory. What can I do about this? Is there any way to use the unicode character for a space?

View 5 Replies View Related

Programming :: Rename File Names : Replace Dots By Spaces, Keep The Extension?

Mar 28, 2011

I am trying to rename a lot of files but need to keep the extension :

the files are films names :

a.b.c.d.***.iso

the result should be replacing "." by spaces " "

this command :

for files in *.iso ; do mv "$files" `echo "$files" | tr '.' ' '`; done

put a space also before the extension iso ??

How can I rename files from

"a.b.c.d.iso" to "a b c d.iso"

View 5 Replies View Related

General :: Getting Blank Spaces In Shell Script?

May 7, 2010

I did the following script:

Code:

DIR=`pwd`;for i in `find . -name GESTION -type d`;do cd $i/..;setfacl -R -m g:directores:rwx,
GESTION;echo $DIR'/'$i;cd $DIR;done

This code do the following actions:

1. Starting inside a folder, it's searching for any folder called "GESTION"

2. Every time a folder called "GESTION" is found, then the script move to its parent folder, and then it applies ACL permissions to the folder GESTION by using the command setfacl.

The problem is that the script doesn't works when there was found a folder with a blank space in its name. I mean:

/dir1/dir2/dir3/GESTION --> this works fine
/dir1/dir2/dir 3/GESTION --> this doesn't works
/dir1/dir2/dir3/2. GESTION --> this doesn't works

View 4 Replies View Related

General :: Remove Spaces From Many File Names Under Cygwin?

Nov 22, 2010

I'm hoping that someone can help me, I need to remove spaces (not replace with underscores) from several thousand files on a system with cygwin.
Can I do this from the shell using rename or mv somehow?

View 4 Replies View Related

General :: Lyx: File Name Error The Directory Path To The Document Cannot Contain Spaces

Sep 9, 2009

trying to write my thesis in Lyx 1.6. It works fine on my windows laptop at home but Not on my work computer. The problem is, when i try to view it in pdflatex it comes with with: Lyx: file name error The directory path to the document cannot contain spaces

View 1 Replies View Related

General :: .bashrc File Adds A Couple Of Tens Of Spaces To The Prompt?

Sep 3, 2010

I got myself a .bashrc file off the net. I checked it beforehand, didn't detect anything bad about it. One thing that's odd about it, is that several spaces are added to the terminal command line.Screenshot:Those spaces are not put there by me. The file can be found here: [URL]..

View 3 Replies View Related

OpenSUSE :: Spaces Allowed In-between Words In A File?

Jan 12, 2011

I tried Suse five or six years ago and ran into an issue that was not comfortable to work with so I went back to windows. The problem was open spaces between words was not permitted with my music files. I have transferred all of my CDs and LPs to MP3 and have a tremendous number of them and the Suse of five years ago required I convert a title like Foggy Mountain Special.mp3 into something resembling Foggy_Mountain_Special.mp3

I don't care to convert literally a hundred thousand titles to fit the latter format. Does the current version of Suse allow the use of spaces between the words or is the 'no open space' convention still required?

View 9 Replies View Related

Programming :: Bash File Names With Spaces?

Jul 24, 2010

I have a laptop that I am in through SSH. The laptop does not have an Xwindow system so I am using the program fbi to open an image on my laptop screen from my SSH connection:

fbi -T 8 picture.jpg #this opens the image on the laptops tty8 terminal

I've found that making a for loop does not work with files that contain a space in the name. Something to due with a bug that they call a "feature" that stops the first variable at the first whitespace.

Using a "while" loop is not exactly what i require either seeing as I want to be able to view each image in the directory on screen and tag it accordingly, before it jumps off to the next image, and I'm not sure how to add a pause to a while loop.

How do I make a Bash script and loop Variables handle files like "files that contain spaces.jpg"

View 5 Replies View Related

Slackware :: Are TABS Replaceable By Spaces In An Xml File

Jun 12, 2011

Kernel 2.6.21.5, slack 12.0 I have a file beginning with <?xml version=1.0?>. May I replace tabs by spaces in it?

View 6 Replies View Related

Software :: Retain Multiple Spaces And Tabs In A File By C-sh File Operation?

Feb 21, 2011

Iam reading a file using C-sh script after manipulating the variables I need to dump into a new file. This in working fine but I couldn't retain the multiple spaces and tabs in a same line. For readability I want to print it back as I read. Now script treating multiple tabs as onl tab or space.

View 3 Replies View Related

Fedora :: Make A Script In Which Drag A File (with Spaces In File Name )?

Aug 2, 2011

i am trying to make a script in which i can drag a file (with spaces in file name ) and it will scp the file to another computermy code is

Code:
echo "--------------------------------------------"
echo "drag file now"

[code]....

View 7 Replies View Related

Ubuntu :: Replace All Tab Stops In A Text File With 4 Spaces?

May 18, 2011

How can I make vi and nano such that when I press the tab key, it automatically replaces the tab with 4 spaces?

View 5 Replies View Related

Programming :: Reading And Writing White Spaces To A File?

Dec 2, 2010

I am trying to read a file character wise and trying to write the same character to another file. In this process, I unable to read and write white spaces successfully to the new file. The script reads the white spaces but while writing the white space is lost. The section of the code, is given below. Please advice how can i read and retain the white space while writing to a new file.

Code:

if [ -s f_test.txt ] && [ -f f_test.txt ]; then
echo "File Exists !!"
while read -n1 char; do

[code]....

View 2 Replies View Related

Programming :: Replace Spaces With Underscores In File Names?

Jan 11, 2011

I often get files with many spaces as part of their names. I would like to automatically replace these spaces with underscores, but otherwise not change the file name. Is there a way to do this task with just the bash shell?

View 4 Replies View Related

General :: Using Tilde And Spaces

May 26, 2010

I'm trying to use a tilde '~' for a filename. This works fine normally Code: rm ~/File
But when I have a file with a space in in and enclose it in quotes it takes it literally.If a word begins with an unquoted tilde character (�~�), all of the characters up to the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix.

View 5 Replies View Related

General :: How To Kill A Process With Name Having Spaces

Dec 10, 2010

A process with name=example can be killed by killall -9 example

How to kill multiple instances of following command which contain spaces?

"valgrind --tool=lackey ./testcases/kernel/syscalls/waitpid/waitpid03"

Following command returns valgrind --tool=lackey ./testcases/kernel/syscalls/waitpid/waitpid03: No such file or directory

View 3 Replies View Related

General :: Replace Multiple Spaces By One Tab

Feb 2, 2011

Ive some textfiles which contains some colums seperated by a various number of spaces, but instead i need one single tab as a seperator.

View 5 Replies View Related

General :: Replacing A Line With Spaces?

Jan 5, 2011

I have a line like

port = 2566

I want to replace it as

port = 8080

how to do this in shell script. when i tried to do this with sed

sed -i 's/port=.*/port='$3'/' /root/$2

it is not recognizing spaces , it works only if line is port=2566 .

View 6 Replies View Related

General :: Running SCP Command With Spaces?

Jan 21, 2010

I am trying to run an scp command on my linux server, this is working fine, however I changed the output folder to one which has spaces and now when run, it's coming up saying SCP ambiguous target

Here's my string:
expect -c 'spawn scp -r /var/lib/asterisk/backups/Everyday/ administrator@192.1.1.1:
/Volumes/Data1/My Backup Folder/ ; expect assword ; send "MYPASSWORD " ; interact;'

View 4 Replies View Related

General :: Convert Tabs To Spaces In Many Files?

Jul 2, 2010

I have a lot of files with tabs littered throughout, and I'd like to convert them all into spaces. I know about the expand command, but unfortunately I would have to type out every single file using it. Is there any easier way to do this on Linux?

View 2 Replies View Related

General :: Bash Command To Remove Spaces

Sep 14, 2010

I am reading the output of /proc/acpi/thermal_zone/ATF0/temperature in a program to read my CPU temp. I am using cat like the following:

Code:
#cat /proc/acpi/thermal_zone/ATF0/temperature
temperature: 49 C

I basically want to get rid of the spaces in between temperature and the actual temperature. Is there a command I can pipe the cat output to, to remove the spaces. I have seen suggestions for sed, or tr, but for some reason I cannot get them to work properly.

View 14 Replies View Related

General :: Replaces Empty Spaces By Underscore?

Mar 11, 2011

my requirement is i need to copy mail subject to a text file and create one directory from the name of subject.

my MAIL subject is like this :

Quote:

Subject:Thanks to linuxquestions.org

i copied the mail subject to a file. and now the issue is to creating a directory.

now i want to create a directory without empty spaces, insted of space replace _ in that place.

i want out put like this.

Quote:

Thanks_to_linuxquestions.org

View 5 Replies View Related

General :: Spaces In Command Line Switches

Oct 6, 2010

I am trying to encode files via mencoder. The file name has spaces in it. "test file.mkv". When I manually type the command in the terminal, everything works. But when I use a bash script (I'm reading it from a file) it doesn't. It gives me

Code:
File not found: '"test'
Below is the bash script I wrote

Code:
#!/bin/bash
# For testing, we have already built a file list, so just use that.
# ls *.mkv>files.lst
exec 10<files.lst
let count=0
while read -u 10 FILE; do
LINE="mencoder -of lavf -lavfopts format=mp4 -vf scale=1024:-3 -ovc x264 -x264encopts crf=28:vbv_maxrate=1500:nocabac:global_header:bframes=0 -oac faac -faacopts br=160:mpeg=4:object=2:raw -channels 2 -srate 48000 "$FILE" -o test.mp4"
echo $LINE
exec $LINE
done

exec 10>&-
files.lst contains only a single line (no newline) with
Code:
test file.mkv

On a related note, when I was first trying this simply on the command line, I had a file that had a double exclamation point. I found out that that is a shortcut of some kind for the previous command. My kludge to get around this was to try to execute a single exclamation point as a command, then to change the double exclamation point to a quadruple exclamation point. Is there a proper way (escape sequence or something) to pass double exclamation points to a command?

View 2 Replies View Related

General :: Ubuntu : Delete The Extra Spaces?

Jul 28, 2010

I want to ask a question regarding the terminal in ubuntu. When i deleted some lines in the config files for example, there will be those so-called extra spaces left after deleting and i can't seem to delete those spaces and 'pull' up the lines below. So, how to delete those extra spaces?

View 13 Replies View Related

General :: Access Files With Spaces From Command Line?

Mar 17, 2011

How do I access files with spaces from the command line?
for example I want to go to a file called "New File" and let's say is in Downloads/Books/(and here is the file)
how do I input the space since the command line doesn't recognize it?

View 2 Replies View Related

General :: Selectively Remove Blank Spaces From String?

Oct 7, 2009

need all spaces between two letters or a letter and a number exchanged for an underscore, but all spaces between a letter and other characters need to remain. One example for clarity:

Input:

force -- lamin 90 [label]
active A -- generation [label]

needed Output:

force -- lamin_90 [label]
active_A -- generation [label]

I tried solving this with sed but obviously s/ /_/g does not work, nor does any s/[a-zA-z0-9] [a-zA-z0-9]/[a-zA-z0-9]_[a-zA-z0-9]/g , because you just can't do this...

View 2 Replies View Related

General :: Search A String Having Spaces / Slashes / Colons In Vi Editor

Feb 2, 2010

I need to seach a string containing

the substring of 'New Request object:'

and

the substring of '/0x2ab46b1f90' in vi editor,

how do I accomplish that?

View 7 Replies View Related

General :: Find List Of Table Spaces In Oracle In Unix?

May 11, 2011

command to find list of table spaces in oracle in unix

View 1 Replies View Related

Fedora :: Listing Subdirectories With Spaces?

May 19, 2011

I have want to list sub-directories with spaces but am facing the following problem:

My subdirectories are:
FirstDirectory
Directory with spaces
if I use
Code:
for directory in "`find . -type d`"

[Code]...

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved